From a11d3729ecf9e33f069e0a427d4e60ae1e69fe46 Mon Sep 17 00:00:00 2001 From: lostinlight Date: Thu, 5 Jul 2018 07:07:30 +0300 Subject: [PATCH] Fix crystal ball --- themes/starter/gulpfile.js | 19 ++++++++++++------- themes/starter/webpack.config.js | 6 ++++-- 2 files changed, 16 insertions(+), 9 deletions(-) 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$/ }, ], - }, + } };