mirror of
https://github.com/GenZmeY/casper-i18n.git
synced 2024-11-10 10:28:04 +00:00
06c8020c16
- use the new, simpler format - sourcemap and watch support is built in, so these plugins can be removed - remove js filter - not sure what that did :/ - simplified task structure
81 lines
1.9 KiB
JavaScript
81 lines
1.9 KiB
JavaScript
const {series, watch, src, dest} = require('gulp');
|
|
const pump = require('pump');
|
|
|
|
// gulp plugins and utils
|
|
var livereload = require('gulp-livereload');
|
|
var postcss = require('gulp-postcss');
|
|
var zip = require('gulp-zip');
|
|
var uglify = require('gulp-uglify');
|
|
var beeper = require('beeper');
|
|
|
|
// postcss plugins
|
|
var autoprefixer = require('autoprefixer');
|
|
var colorFunction = require('postcss-color-function');
|
|
var cssnano = require('cssnano');
|
|
var customProperties = require('postcss-custom-properties');
|
|
var easyimport = require('postcss-easy-import');
|
|
|
|
function serve(done) {
|
|
livereload.listen();
|
|
done();
|
|
}
|
|
|
|
const handleError = (done) => {
|
|
return function (err) {
|
|
if (err) {
|
|
beeper();
|
|
}
|
|
return done(err);
|
|
};
|
|
};
|
|
|
|
function css(done) {
|
|
var processors = [
|
|
easyimport,
|
|
customProperties,
|
|
colorFunction(),
|
|
autoprefixer({browsers: ['last 2 versions']}),
|
|
cssnano()
|
|
];
|
|
|
|
pump([
|
|
src('assets/css/*.css', {sourcemaps: true}),
|
|
postcss(processors),
|
|
dest('assets/built/', {sourcemaps: '.'}),
|
|
livereload()
|
|
], handleError(done));
|
|
}
|
|
|
|
function js(done) {
|
|
pump([
|
|
src('assets/js/*.js', {sourcemaps: true}),
|
|
uglify(),
|
|
dest('assets/built/', {sourcemaps: '.'}),
|
|
livereload()
|
|
], handleError(done));
|
|
}
|
|
|
|
function zipper(done) {
|
|
var targetDir = 'dist/';
|
|
var themeName = require('./package.json').name;
|
|
var filename = themeName + '.zip';
|
|
|
|
pump([
|
|
src([
|
|
'**',
|
|
'!node_modules', '!node_modules/**',
|
|
'!dist', '!dist/**'
|
|
]),
|
|
zip(filename),
|
|
dest(targetDir)
|
|
], handleError(done));
|
|
}
|
|
|
|
const watcher = () => watch('assets/css/**', css);
|
|
const build = series(css, js);
|
|
const dev = series(build, serve, watcher);
|
|
|
|
exports.build = build;
|
|
exports.zip = series(build, zipper);
|
|
exports.default = dev;
|