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');
|
|
|
|
|
2019-08-18 12:49:05 +02:00
|
|
|
const watch = require('gulp-watch');
|
|
|
|
|
2019-08-25 23:27:11 +02:00
|
|
|
const filter = require('gulp-filter');
|
2019-08-18 12:49:05 +02:00
|
|
|
|
|
|
|
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 = {
|
2019-08-25 22:20:41 +02:00
|
|
|
css: 'nighttab.min.css',
|
|
|
|
js: 'nighttab.min.js'
|
2019-08-08 13:32:34 +02:00
|
|
|
}
|
|
|
|
|
2019-08-18 12:49:05 +02:00
|
|
|
const jsDependencies = [
|
|
|
|
path.nodeModules + '/html5sortable/dist/html5sortable.min.js',
|
2019-11-19 09:01:57 +01:00
|
|
|
path.nodeModules + '/invert-color/lib/invert.min.js',
|
2020-01-14 13:19:45 +01:00
|
|
|
path.nodeModules + '/moment/min/moment.min.js',
|
2020-01-14 13:16:13 +01:00
|
|
|
path.nodeModules + '/webfontloader/webfontloader.js'
|
2019-08-18 12:49:05 +02:00
|
|
|
]
|
2019-08-08 13:32:34 +02:00
|
|
|
|
2019-08-26 00:12:31 +02:00
|
|
|
const cssFiles = [
|
|
|
|
path.src + '/css/reset.css',
|
|
|
|
path.src + '/css/variables.css',
|
|
|
|
path.src + '/css/utilities.css',
|
|
|
|
path.src + '/css/base.css',
|
|
|
|
path.src + '/css/layout.css',
|
|
|
|
path.src + '/css/edge.css',
|
|
|
|
path.src + '/css/animation.css',
|
|
|
|
path.src + '/css/fonts.css',
|
|
|
|
path.src + '/css/icons.css',
|
|
|
|
path.src + '/css/state.css',
|
|
|
|
path.src + '/css/typography.css',
|
|
|
|
path.src + '/css/spacing.css',
|
|
|
|
path.src + '/css/button.css',
|
|
|
|
path.src + '/css/form.css',
|
|
|
|
path.src + '/css/shade.css',
|
|
|
|
path.src + '/css/modal.css',
|
|
|
|
path.src + '/css/tip.css',
|
|
|
|
path.src + '/css/menu.css',
|
|
|
|
path.src + '/css/header.css',
|
|
|
|
path.src + '/css/date.css',
|
|
|
|
path.src + '/css/clock.css',
|
|
|
|
path.src + '/css/greeting.css',
|
|
|
|
path.src + '/css/transitional.css',
|
|
|
|
path.src + '/css/search.css',
|
|
|
|
path.src + '/css/background.css',
|
2019-10-19 11:52:33 +02:00
|
|
|
path.src + '/css/group.css',
|
2019-08-26 00:12:31 +02:00
|
|
|
path.src + '/css/link.css',
|
2019-12-24 12:56:52 +01:00
|
|
|
path.src + '/css/theme.css',
|
2019-08-26 00:12:31 +02:00
|
|
|
path.src + '/css/auto-suggest.css',
|
|
|
|
path.src + '/css/fontawesome.css'
|
|
|
|
]
|
|
|
|
|
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',
|
2019-10-21 00:41:12 +02:00
|
|
|
path.src + '/js/dropdown.js',
|
2019-08-18 12:49:05 +02:00
|
|
|
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() {
|
2019-08-26 00:12:31 +02:00
|
|
|
return src(cssFiles)
|
2019-08-18 12:49:05 +02:00
|
|
|
.pipe(concat(filename.css))
|
|
|
|
.pipe(csso())
|
|
|
|
.pipe(dest(path.build + '/css'))
|
|
|
|
},
|
|
|
|
js: function() {
|
2019-08-25 23:27:11 +02:00
|
|
|
const noVendors = filter(jsFiles, {
|
|
|
|
restore: true
|
|
|
|
});
|
|
|
|
return src(jsDependencies.concat(jsFiles), {
|
2019-08-25 22:19:30 +02:00
|
|
|
sourcemaps: true
|
|
|
|
})
|
2019-08-25 23:27:11 +02:00
|
|
|
.pipe(noVendors)
|
|
|
|
.pipe(uglify())
|
|
|
|
.pipe(noVendors.restore)
|
2019-08-18 12:49:05 +02:00
|
|
|
.pipe(concat(filename.js))
|
|
|
|
.pipe(dest(path.build + '/js', {
|
|
|
|
sourcemaps: '.'
|
|
|
|
}))
|
|
|
|
}
|
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() {
|
2019-08-26 00:12:31 +02:00
|
|
|
watch(cssFiles, {
|
2019-08-18 12:49:05 +02:00
|
|
|
ignoreInitial: false
|
|
|
|
}, function() {
|
2019-08-26 00:12:31 +02:00
|
|
|
return src(cssFiles)
|
2019-08-18 12:49:05 +02:00
|
|
|
.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)
|
2019-08-25 23:27:11 +02:00
|
|
|
exports.build = parallel(build.manifest, build.html, build.fonts, build.icons, build.css, build.js)
|