2019-08-08 13:32:34 +02:00
|
|
|
const {
|
|
|
|
src,
|
|
|
|
dest,
|
|
|
|
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');
|
|
|
|
|
|
|
|
const folder = {
|
|
|
|
src: 'src',
|
2019-08-08 15:30:30 +02:00
|
|
|
dest: 'dest/web',
|
|
|
|
nodeModules: 'node_modules',
|
2019-08-08 13:32:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const filename = {
|
|
|
|
css: "nighttab.min.css",
|
|
|
|
js: "nighttab.min.js"
|
|
|
|
}
|
|
|
|
|
|
|
|
function manifest() {
|
|
|
|
return src(folder.src + '/manifest.json')
|
2019-08-08 15:18:49 +02:00
|
|
|
.pipe(dest(folder.dest))
|
2019-08-08 13:32:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function html() {
|
|
|
|
return src(folder.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
|
|
|
|
}))
|
2019-08-08 15:18:49 +02:00
|
|
|
.pipe(dest(folder.dest))
|
2019-08-08 13:32:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function fonts() {
|
|
|
|
return src(folder.src + '/fonts/**/*.*')
|
2019-08-08 15:18:49 +02:00
|
|
|
.pipe(dest(folder.dest + '/fonts'))
|
2019-08-08 13:32:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function icons() {
|
|
|
|
return src(folder.src + '/icons/**/*.*')
|
2019-08-08 15:18:49 +02:00
|
|
|
.pipe(dest(folder.dest + '/icons'))
|
2019-08-08 13:32:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function css() {
|
|
|
|
return src(folder.src + '/css/*.css')
|
|
|
|
.pipe(concat(filename.css))
|
|
|
|
.pipe(csso())
|
2019-08-08 15:18:49 +02:00
|
|
|
.pipe(dest(folder.dest + '/css'))
|
2019-08-08 13:32:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function js() {
|
|
|
|
return src([
|
2019-08-08 15:30:30 +02:00
|
|
|
folder.nodeModules + '/html5sortable/dist/html5sortable.min.js',
|
|
|
|
folder.nodeModules + '/invert-color/lib/invert.min.js',
|
2019-08-08 13:32:34 +02:00
|
|
|
folder.src + '/js/helper.js',
|
|
|
|
folder.src + '/js/data.js',
|
|
|
|
folder.src + '/js/fontawesome.js',
|
|
|
|
folder.src + '/js/update.js',
|
|
|
|
folder.src + '/js/state.js',
|
|
|
|
folder.src + '/js/bookmarks.js',
|
|
|
|
folder.src + '/js/control.js',
|
|
|
|
folder.src + '/js/menu.js',
|
|
|
|
folder.src + '/js/header.js',
|
|
|
|
folder.src + '/js/modal.js',
|
|
|
|
folder.src + '/js/tip.js',
|
|
|
|
folder.src + '/js/shade.js',
|
|
|
|
folder.src + '/js/theme.js',
|
|
|
|
folder.src + '/js/date.js',
|
|
|
|
folder.src + '/js/greeting.js',
|
|
|
|
folder.src + '/js/transitional.js',
|
|
|
|
folder.src + '/js/clock.js',
|
|
|
|
folder.src + '/js/search.js',
|
|
|
|
folder.src + '/js/link.js',
|
|
|
|
folder.src + '/js/version.js',
|
|
|
|
folder.src + '/js/keyboard.js',
|
|
|
|
folder.src + '/js/background.js',
|
|
|
|
folder.src + '/js/layout.js',
|
|
|
|
folder.src + '/js/auto-suggest.js',
|
|
|
|
folder.src + '/js/pagelock.js',
|
|
|
|
folder.src + '/js/edge.js',
|
|
|
|
folder.src + '/js/init.js',
|
|
|
|
])
|
|
|
|
.pipe(concat(filename.js))
|
|
|
|
.pipe(uglify())
|
2019-08-08 15:18:49 +02:00
|
|
|
.pipe(dest(folder.dest + '/js', {
|
2019-08-08 13:32:34 +02:00
|
|
|
sourcemaps: '.'
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.manifest = manifest;
|
|
|
|
exports.html = html;
|
|
|
|
exports.fonts = fonts;
|
|
|
|
exports.icons = icons;
|
|
|
|
exports.css = css;
|
|
|
|
exports.js = js;
|
|
|
|
exports.default = parallel(manifest, html, fonts, icons, css, js);
|