2019-08-08 13:32:34 +02:00
|
|
|
const {
|
|
|
|
src,
|
|
|
|
dest,
|
2019-08-18 12:49:05 +02:00
|
|
|
series,
|
2019-08-08 13:32:34 +02:00
|
|
|
parallel
|
|
|
|
} = require('gulp');
|
|
|
|
|
|
|
|
const csso = require('gulp-csso');
|
|
|
|
|
|
|
|
const concat = require('gulp-concat');
|
|
|
|
|
|
|
|
const uglify = require('gulp-uglify');
|
|
|
|
|
|
|
|
const replace = require('gulp-replace');
|
|
|
|
|
|
|
|
const htmlmin = require('gulp-htmlmin');
|
|
|
|
|
2019-08-18 12:49:05 +02:00
|
|
|
const watch = require('gulp-watch');
|
|
|
|
|
|
|
|
const clean = require('gulp-clean');
|
|
|
|
|
|
|
|
const path = {
|
2019-08-08 13:32:34 +02:00
|
|
|
src: 'src',
|
2019-08-18 12:49:05 +02:00
|
|
|
dev: 'dev',
|
|
|
|
build: 'build/web',
|
2019-08-08 15:30:30 +02:00
|
|
|
nodeModules: 'node_modules',
|
2019-08-08 13:32:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const filename = {
|
|
|
|
css: "nighttab.min.css",
|
2019-08-18 12:49:05 +02:00
|
|
|
jsDependencies: "nighttab.dependencies.js",
|
|
|
|
jsFiles: "nighttab.files.js",
|
2019-08-08 13:32:34 +02:00
|
|
|
js: "nighttab.min.js"
|
|
|
|
}
|
|
|
|
|
2019-08-18 12:49:05 +02:00
|
|
|
const jsDependencies = [
|
|
|
|
path.nodeModules + '/html5sortable/dist/html5sortable.min.js',
|
|
|
|
path.nodeModules + '/invert-color/lib/invert.min.js'
|
|
|
|
]
|
2019-08-08 13:32:34 +02:00
|
|
|
|
2019-08-18 12:49:05 +02:00
|
|
|
const jsFiles = [
|
|
|
|
path.src + '/js/helper.js',
|
|
|
|
path.src + '/js/data.js',
|
|
|
|
path.src + '/js/fontawesome.js',
|
|
|
|
path.src + '/js/update.js',
|
|
|
|
path.src + '/js/state.js',
|
|
|
|
path.src + '/js/bookmarks.js',
|
|
|
|
path.src + '/js/control.js',
|
|
|
|
path.src + '/js/menu.js',
|
|
|
|
path.src + '/js/header.js',
|
|
|
|
path.src + '/js/modal.js',
|
|
|
|
path.src + '/js/tip.js',
|
|
|
|
path.src + '/js/shade.js',
|
|
|
|
path.src + '/js/theme.js',
|
|
|
|
path.src + '/js/date.js',
|
|
|
|
path.src + '/js/greeting.js',
|
|
|
|
path.src + '/js/transitional.js',
|
|
|
|
path.src + '/js/clock.js',
|
|
|
|
path.src + '/js/search.js',
|
|
|
|
path.src + '/js/link.js',
|
|
|
|
path.src + '/js/version.js',
|
|
|
|
path.src + '/js/keyboard.js',
|
|
|
|
path.src + '/js/background.js',
|
|
|
|
path.src + '/js/layout.js',
|
|
|
|
path.src + '/js/auto-suggest.js',
|
|
|
|
path.src + '/js/pagelock.js',
|
|
|
|
path.src + '/js/edge.js',
|
|
|
|
path.src + '/js/init.js'
|
|
|
|
]
|
2019-08-08 13:32:34 +02:00
|
|
|
|
2019-08-18 12:49:05 +02:00
|
|
|
const build = {
|
|
|
|
manifest: function() {
|
|
|
|
return src(path.src + '/manifest.json')
|
|
|
|
.pipe(dest(path.build))
|
|
|
|
},
|
|
|
|
html: function() {
|
|
|
|
return src(path.src + '/index.html')
|
|
|
|
.pipe(replace(/\<\!\-\-\ css\-block\ \-\-\>([\s\S]*)\<\!\-\-\ end\-css\-block\ \-\-\>/mg, '<link rel="stylesheet" href="css/' + filename.css + '">'))
|
|
|
|
.pipe(replace(/\<\!\-\-\ js\-block\ \-\-\>([\s\S]*)\<\!\-\-\ end\-js\-block\ \-\-\>/mg, '<script src="js/' + filename.js + '"></script>'))
|
|
|
|
.pipe(htmlmin({
|
|
|
|
collapseWhitespace: true
|
|
|
|
}))
|
|
|
|
.pipe(dest(path.build))
|
|
|
|
},
|
|
|
|
fonts: function() {
|
|
|
|
return src(path.src + '/fonts/**/*.*')
|
|
|
|
.pipe(dest(path.build + '/fonts'))
|
|
|
|
},
|
|
|
|
icons: function() {
|
|
|
|
return src(path.src + '/icons/**/*.*')
|
|
|
|
.pipe(dest(path.build + '/icons'))
|
|
|
|
},
|
|
|
|
css: function() {
|
|
|
|
return src(path.src + '/css/*.css')
|
|
|
|
.pipe(concat(filename.css))
|
|
|
|
.pipe(csso())
|
|
|
|
.pipe(dest(path.build + '/css'))
|
|
|
|
},
|
|
|
|
jsDependencies: function() {
|
2019-08-25 22:19:30 +02:00
|
|
|
return src(jsDependencies, {
|
|
|
|
sourcemaps: true
|
|
|
|
})
|
2019-08-18 12:49:05 +02:00
|
|
|
.pipe(concat(filename.jsDependencies))
|
2019-08-25 22:19:30 +02:00
|
|
|
.pipe(dest(path.build + '/js', {
|
|
|
|
sourcemaps: true
|
|
|
|
}))
|
2019-08-18 12:49:05 +02:00
|
|
|
},
|
|
|
|
jsFiles: function() {
|
2019-08-25 22:19:30 +02:00
|
|
|
return src(jsFiles, {
|
|
|
|
sourcemaps: true
|
|
|
|
})
|
2019-08-18 12:49:05 +02:00
|
|
|
.pipe(concat(filename.jsFiles))
|
|
|
|
.pipe(uglify())
|
|
|
|
.pipe(dest(path.build + '/js', {
|
2019-08-25 22:19:30 +02:00
|
|
|
sourcemaps: true
|
2019-08-18 12:49:05 +02:00
|
|
|
}))
|
|
|
|
},
|
|
|
|
js: function() {
|
2019-08-25 22:19:30 +02:00
|
|
|
return src([
|
|
|
|
path.build + '/js/' + filename.jsDependencies,
|
|
|
|
path.build + '/js/' + filename.jsFiles
|
|
|
|
], {
|
|
|
|
sourcemaps: true
|
|
|
|
})
|
2019-08-18 12:49:05 +02:00
|
|
|
.pipe(concat(filename.js))
|
|
|
|
.pipe(dest(path.build + '/js', {
|
|
|
|
sourcemaps: '.'
|
|
|
|
}))
|
|
|
|
},
|
|
|
|
jsClean: function() {
|
2019-08-25 22:19:30 +02:00
|
|
|
return src([
|
|
|
|
path.build + '/js/' + filename.jsDependencies,
|
|
|
|
path.build + '/js/' + filename.jsFiles
|
|
|
|
])
|
2019-08-18 12:49:05 +02:00
|
|
|
.pipe(clean())
|
|
|
|
}
|
2019-08-08 13:32:34 +02:00
|
|
|
}
|
|
|
|
|
2019-08-18 12:49:05 +02:00
|
|
|
const dev = {
|
|
|
|
manifest: function() {
|
|
|
|
watch(path.src + '/manifest.json', {
|
|
|
|
ignoreInitial: false
|
|
|
|
}, function() {
|
|
|
|
return src(path.src + '/manifest.json')
|
|
|
|
.pipe(dest(path.dev))
|
|
|
|
})
|
|
|
|
},
|
|
|
|
html: function() {
|
|
|
|
watch(path.src + '/index.html', {
|
|
|
|
ignoreInitial: false
|
|
|
|
}, function() {
|
|
|
|
return src(path.src + '/index.html')
|
|
|
|
.pipe(dest(path.dev))
|
|
|
|
})
|
|
|
|
},
|
|
|
|
fonts: function() {
|
|
|
|
watch(path.src + '/fonts/**/*.*', {
|
|
|
|
ignoreInitial: false
|
|
|
|
}, function() {
|
|
|
|
return src(path.src + '/fonts/**/*.*')
|
|
|
|
.pipe(dest(path.dev + '/fonts'))
|
|
|
|
})
|
|
|
|
},
|
|
|
|
icons: function() {
|
|
|
|
watch(path.src + '/icons/**/*.*', {
|
|
|
|
ignoreInitial: false
|
|
|
|
}, function() {
|
|
|
|
return src(path.src + '/icons/**/*.*')
|
|
|
|
.pipe(dest(path.dev + '/icons'))
|
|
|
|
})
|
|
|
|
},
|
|
|
|
css: function() {
|
|
|
|
watch(path.src + '/css/*.css', {
|
|
|
|
ignoreInitial: false
|
|
|
|
}, function() {
|
|
|
|
return src(path.src + '/css/*.css')
|
|
|
|
.pipe(dest(path.dev + '/css'))
|
|
|
|
})
|
|
|
|
},
|
|
|
|
js: function() {
|
|
|
|
watch(jsFiles, {
|
|
|
|
ignoreInitial: false
|
|
|
|
}, function() {
|
|
|
|
return src(jsFiles)
|
|
|
|
.pipe(dest(path.dev + '/js'))
|
|
|
|
})
|
|
|
|
}
|
2019-08-08 13:32:34 +02:00
|
|
|
}
|
|
|
|
|
2019-08-18 12:49:05 +02:00
|
|
|
exports.dev = parallel(dev.manifest, dev.html, dev.fonts, dev.icons, dev.css, dev.js)
|
|
|
|
exports.build = series(parallel(build.manifest, build.html, build.fonts, build.icons, build.css), series(build.jsDependencies, build.jsFiles, build.js), build.jsClean)
|