Fix crystal ball

This commit is contained in:
lostinlight 2018-07-05 07:07:30 +03:00
parent afdbabfaf2
commit a11d3729ec
2 changed files with 16 additions and 9 deletions

View file

@ -16,7 +16,7 @@
stylelint = require('../../node_modules/gulp-stylelint'), stylelint = require('../../node_modules/gulp-stylelint'),
tinypng = require('../../node_modules/gulp-tinypng-extended'), tinypng = require('../../node_modules/gulp-tinypng-extended'),
uglify = require('../../node_modules/gulp-uglify'), uglify = require('../../node_modules/gulp-uglify'),
webpack = require('webpack-stream'); webpack = require('../../node_modules/webpack-stream');
function customPlumber (errTitle) { function customPlumber (errTitle) {
return plumber({ return plumber({
@ -60,9 +60,15 @@
.pipe(gulp.dest('source/css/')) .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 // Scripts
gulp.task('scripts:serve', function() { 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(sourcemaps.init())
.pipe(babel({ .pipe(babel({
presets: ['es2015'] presets: ['es2015']
@ -70,15 +76,14 @@
.pipe(customPlumber('Ouch! Error Running Scripts')) .pipe(customPlumber('Ouch! Error Running Scripts'))
.pipe(eslint()) .pipe(eslint())
.pipe(eslint.format()) .pipe(eslint.format())
.pipe(webpack( require('./webpack.config.js') ))
//.pipe(concat('main.js')) //.pipe(concat('main.js'))
.pipe(rename({ suffix: '.min' })) // for using in dev mode .pipe(rename({ suffix: '.min' }))
.pipe(sourcemaps.write('./')) .pipe(sourcemaps.write('./'))
.pipe(gulp.dest('source/js/')); .pipe(gulp.dest('source/js/'));
}); });
gulp.task('scripts:build', function() { 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({ .pipe(babel({
presets: ['es2015'] presets: ['es2015']
})) }))
@ -140,10 +145,10 @@
// Development Mode // Development Mode
gulp.task('default', function () { 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 // Production Mode
gulp.task('build', function (done) { gulp.task('build', function (done) {
runSequence('clean', 'styles:build', 'scripts:build', 'vendor', done); runSequence('clean', 'styles:build', 'scripts:build', 'webpack', 'vendor', done);
}); });

View file

@ -1,10 +1,12 @@
const UglifyJsPlugin = require('../../node_modules/uglifyjs-webpack-plugin');
module.exports = { module.exports = {
entry: { entry: {
main: './source/assets/scripts/crystalball' main: './source/assets/scripts/crystalball'
}, },
output: { output: {
filename: 'ball.js', filename: 'ball.min.js',
}, },
module: { module: {
rules: [ rules: [
@ -12,5 +14,5 @@ module.exports = {
test: /\.js$/ test: /\.js$/
}, },
], ],
}, }
}; };