Revision 3d2f3df0e68f2f0f2698ad03e41f08ff56758359 authored by ottojolanki on 28 April 2021, 17:30:00 UTC, committed by ottojolanki on 28 April 2021, 17:30:00 UTC
1 parent 76220b7
Raw File
gulpfile.js
const gulp = require('gulp');
const log = require('fancy-log');
const webpack = require('webpack');

const setProduction = (cb) => {
    process.env.NODE_ENV = 'production';
    if (cb) {
        cb();
    }
};

const webpackOnBuild = done => (err, stats) => {
    if (err) {
        throw new log.error(err);
    }
    log(stats.toString({
        colors: true,
        excludeAssets: [/.*ckeditor.*/],
    }));
    if (done) {
        done(err);
    }
};

const webpackSetup = (cb) => {
    const webpackConfig = require('./webpack.config.js');
    webpack(webpackConfig).run(webpackOnBuild(cb));
};

const watch = (cb) => {
    const webpackConfig = require('./webpack.config.js');
    webpack(webpackConfig).watch(300, webpackOnBuild(cb));
};

const series = gulp.series;

gulp.task('default', series(webpackSetup, watch));
gulp.task('dev', series('default'));
gulp.task('build', series(setProduction, webpackSetup));
back to top