gulpfile.js
gulp --v 3.9.0
var gulp = require('gulp');
var webpackStream = require('webpack-stream');
var webpack = require('webpack');
var browserSync = require('browser-sync').create();
var sass = require('gulp-sass');
var commonsPlugin =
new webpack.optimize.CommonsChunkPlugin('./js/common.js');
gulp.task('webpack', function() {
return gulp.src('./src/script/entry.js')
.pipe(webpackStream( require('./webpack.config.js') ))
.pipe(gulp.dest('./dist'))
.pipe(browserSync.stream());
});
// Static Server + watching scss/html files
gulp.task('serve', ['sass'], function() {
browserSync.init({
server: "./dist"
});
gulp.watch("./src/stylesheets/**/*.scss", ['sass']);
gulp.watch("./src/script/**/*.js", ['webpack']);
gulp.watch("./dist/*.html").on('change', browserSync.reload);
});
// Compile sass into CSS & auto-inject into browsers
gulp.task('sass', function() {
return gulp.src("./src/stylesheets/**/*.scss")
.pipe(sass())
.pipe(gulp.dest("./dist/css"))
.pipe(browserSync.stream());
});
gulp.task('default', ['serve']);
webpack.config.js
webpack --v 1.12.13
var webpack = require('webpack');
var commonsPlugin =
new webpack.optimize.CommonsChunkPlugin('./js/common.js');
module.exports = {
entry: {
registration: "./src/script/registration.js",
application: "./src/script/app.js"
},
output: {
path: __dirname,
filename: "./js/[name].js"
},
plugins: [commonsPlugin]
};