diff --git a/themes/starter/gulpfile.js b/themes/starter/gulpfile.js index 3e04a31..4fa910e 100644 --- a/themes/starter/gulpfile.js +++ b/themes/starter/gulpfile.js @@ -16,7 +16,7 @@ stylelint = require('../../node_modules/gulp-stylelint'), tinypng = require('../../node_modules/gulp-tinypng-extended'), uglify = require('../../node_modules/gulp-uglify'), - webpack = require('webpack-stream'); + webpack = require('../../node_modules/webpack-stream'); function customPlumber (errTitle) { return plumber({ @@ -60,9 +60,15 @@ .pipe(gulp.dest('source/css/')) }); + gulp.task('webpack', function() { + return gulp.src('source/assets/scripts/crystalball.js') + .pipe(webpack( require('./webpack.config.js') )) + .pipe(gulp.dest('source/js/')); + }); + // Scripts gulp.task('scripts:serve', function() { - return gulp.src('source/assets/scripts/*.js') + return gulp.src(['source/assets/scripts/*.js', '!source/assets/scripts/*ball.js']) .pipe(sourcemaps.init()) .pipe(babel({ presets: ['es2015'] @@ -70,15 +76,14 @@ .pipe(customPlumber('Ouch! Error Running Scripts')) .pipe(eslint()) .pipe(eslint.format()) - .pipe(webpack( require('./webpack.config.js') )) //.pipe(concat('main.js')) - .pipe(rename({ suffix: '.min' })) // for using in dev mode + .pipe(rename({ suffix: '.min' })) .pipe(sourcemaps.write('./')) .pipe(gulp.dest('source/js/')); }); gulp.task('scripts:build', function() { - return gulp.src('source/assets/scripts/*.js') + return gulp.src(['source/assets/scripts/*.js', '!source/assets/scripts/*ball.js']) .pipe(babel({ presets: ['es2015'] })) @@ -140,10 +145,10 @@ // Development Mode gulp.task('default', function () { - runSequence('styles:lint', 'styles:serve', 'scripts:serve', 'vendor', 'watch'); + runSequence('styles:lint', 'styles:serve', 'webpack', 'scripts:serve', 'vendor', 'watch'); }); // Production Mode gulp.task('build', function (done) { - runSequence('clean', 'styles:build', 'scripts:build', 'vendor', done); + runSequence('clean', 'styles:build', 'scripts:build', 'webpack', 'vendor', done); }); diff --git a/themes/starter/webpack.config.js b/themes/starter/webpack.config.js index 1be3bb4..69f1e06 100644 --- a/themes/starter/webpack.config.js +++ b/themes/starter/webpack.config.js @@ -1,10 +1,12 @@ +const UglifyJsPlugin = require('../../node_modules/uglifyjs-webpack-plugin'); + module.exports = { entry: { main: './source/assets/scripts/crystalball' }, output: { - filename: 'ball.js', + filename: 'ball.min.js', }, module: { rules: [ @@ -12,5 +14,5 @@ module.exports = { test: /\.js$/ }, ], - }, + } };