diff --git a/gulpfile.js b/gulpfile.js index 9b7e7439..3165dd2f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -2,9 +2,10 @@ var gulp = require('gulp'); var eslint = require('gulp-eslint'); var webpack = require('webpack'); -var gulpWebpack = require('gulp-webpack'); +var gulpWebpack = require('webpack-stream'); var Server = require('karma').Server; var argv = require('yargs').argv; +var UglifyJSPlugin = require('uglifyjs-webpack-plugin'); gulp.task('test', ['lint', 'karma']); gulp.task('build', ['lint', 'karma', 'webpack', 'webpack-min']); @@ -13,12 +14,12 @@ var FILE_NAME = 'post-robot'; var MODULE_NAME = 'postRobot'; var WEBPACK_CONFIG = { - devtool: 'source-map', + // devtool: 'source-map', module: { - loaders: [ + rules: [ { test: /\.js$/, - loader: 'babel', + loader: 'babel-loader', query: { presets: ['es2015'], plugins: [ @@ -33,7 +34,7 @@ var WEBPACK_CONFIG = { ] }, resolve: { - modulesDirectories: [ + modules: [ 'node_modules', 'src', 'client' @@ -48,6 +49,9 @@ var WEBPACK_CONFIG = { plugins: [ new webpack.DefinePlugin({ __TEST__: false + }), + new webpack.SourceMapDevToolPlugin({ + filename: '[file].map' }) ], bail: true @@ -64,23 +68,26 @@ var WEBPACK_CONFIG_MIN = Object.assign({}, WEBPACK_CONFIG, { new webpack.DefinePlugin({ __TEST__: false }), - new webpack.optimize.UglifyJsPlugin({ + new webpack.SourceMapDevToolPlugin({ + filename: '[file].map' + }), + new UglifyJSPlugin({ test: /\.js$/, exclude: /(node_modules|bower_components)/, - minimize: true + sourceMap: true }) ] }); gulp.task('webpack', ['lint'], function() { return gulp.src('src/index.js') - .pipe(gulpWebpack(WEBPACK_CONFIG)) + .pipe(gulpWebpack(WEBPACK_CONFIG, webpack)) .pipe(gulp.dest('dist')); }); gulp.task('webpack-min', ['lint'], function() { return gulp.src('src/index.js') - .pipe(gulpWebpack(WEBPACK_CONFIG_MIN)) + .pipe(gulpWebpack(WEBPACK_CONFIG_MIN, webpack)) .pipe(gulp.dest('dist')); }); diff --git a/karma.conf.js b/karma.conf.js index 12e33880..82f699c5 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -43,21 +43,18 @@ module.exports = function(config) { devtool: 'inline-source-map', resolve: { - root: [ - __dirname - ], - - modulesDirectories: [ + modules: [ + __dirname, 'node_modules' ] }, module: { - loaders: [ + rules: [ { test: /\.js$/, exclude: /(dist)/, - loader: 'babel', + loader: 'babel-loader', query: { presets: ['es2015'], plugins: [ diff --git a/package.json b/package.json index fc776cb2..8452d23d 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,6 @@ "gulp": "^3.9.1", "gulp-eslint": "^2.0.0", "gulp-karma": "0.0.5", - "gulp-webpack": "^1.5.0", "istanbul-instrumenter-loader": "^0.2.0", "karma": "^0.13.22", "karma-chrome-launcher": "^1.0.1", @@ -54,13 +53,15 @@ "karma-sinon-chai": "^1.2.0", "karma-sourcemap-loader": "^0.3.7", "karma-spec-reporter": "0.0.26", - "karma-webpack": "^1.7.0", + "karma-webpack": "^2.0.3", "lolex": "^1.5.0", "mocha": "^2.4.5", "phantomjs-prebuilt": "^2.1.7", "sinon": "^1.17.4", "sinon-chai": "^2.8.0", - "webpack": "^1.13.0", + "uglifyjs-webpack-plugin": "^0.3.0", + "webpack": "^2.2.1", + "webpack-stream": "^3.2.0", "yargs": "^4.7.1" }, "dependencies": {