1
0
mirror of https://github.com/Damillora/Yuika synced 2024-11-25 10:37:32 +00:00
Yuika/gulpfile.js

67 lines
1.7 KiB
JavaScript
Raw Normal View History

const { series, watch, src, dest, parallel } = require('gulp');
2019-11-08 20:59:26 +00:00
const livereload = require('gulp-livereload');
const zip = require('gulp-zip');
const concat = require('gulp-concat');
const uglify = require('gulp-uglify');
2019-11-09 10:17:41 +00:00
const cleancss = require('gulp-clean-css');
const webpack = require('webpack-stream');
2019-11-08 20:59:26 +00:00
function serve(done) {
livereload.listen();
done();
}
function hbs() {
2019-11-08 20:59:26 +00:00
return src(['*.hbs', 'partials/**/*.hbs'])
.pipe(livereload());
}
function css() {
2019-11-08 20:59:26 +00:00
return src('assets/css/styles.css')
.pipe(cleancss({ compatibility: 'ie8' }))
.pipe(dest('assets/built/'))
.pipe(livereload())
2019-11-08 20:59:26 +00:00
}
function js() {
return src('assets/js/index.js')
.pipe(
webpack({
mode: 'production'
// Any configuration options...
})
)
2019-11-08 20:59:26 +00:00
.pipe(concat('yuika.js'))
.pipe(uglify())
.pipe(dest('assets/built/', { sourcemaps: '.' }))
2019-11-08 20:59:26 +00:00
.pipe(livereload());
}
2021-07-10 17:56:01 +00:00
const cssWatcher = () => watch(['assets/css/**','node_modules/@damillora/shian/dist/**'], css);
2019-11-08 20:59:26 +00:00
const jsWatcher = () => watch('assets/js/**.js', js);
const hbsWatcher = () => watch(['*.hbs', 'partials/**/*.hbs'], hbs);
const watcher = parallel(cssWatcher, hbsWatcher, jsWatcher);
const build = parallel(css, js);
2019-11-08 20:59:26 +00:00
const dev = series(build, serve, watcher);
function zipper(done) {
const targetDir = 'dist/';
const themeName = require('./package.json').name;
const filename = themeName + '.zip';
return src([
'**',
'!node_modules', '!node_modules/**',
'!dist', '!dist/**'
])
2019-11-08 20:59:26 +00:00
.pipe(zip(filename))
.pipe(dest(targetDir));
}
2019-11-09 10:07:23 +00:00
exports.build = build;
2019-11-08 20:59:26 +00:00
exports.zip = series(build, zipper);
exports.dev = dev;
exports.default = build;