From 2f4867fef85b273f60b8c0b794e4ecf10a59d0d5 Mon Sep 17 00:00:00 2001 From: Christopher Joe Date: Wed, 28 Sep 2016 13:16:43 +1300 Subject: [PATCH] API added watch command to package.json --- package.json | 1 + webpack-dev.config.js | 25 +++++++++++++++++++++++++ webpack.config.js | 3 --- 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 webpack-dev.config.js diff --git a/package.json b/package.json index e711910a3..bcd324344 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ }, "scripts": { "build": "webpack", + "watch": "webpack --config ./webpack-dev.config.js --watch", "css": "WEBPACK_CHILD=css webpack", "lock": "npm-shrinkwrap --dev", "test": "NODE_PATH=\"./client/src:./admin/client/src\" jest", diff --git a/webpack-dev.config.js b/webpack-dev.config.js new file mode 100644 index 000000000..b62f085f2 --- /dev/null +++ b/webpack-dev.config.js @@ -0,0 +1,25 @@ +const webpack = require('webpack'); +const Config = require('./webpack.config'); + +if (Array.isArray(Config)) { + const jsConfig = Config.find((item) => item.name === 'js'); + + jsConfig.plugins = [ + new webpack.ProvidePlugin({ + jQuery: 'jQuery', + $: 'jQuery', + }), + // Most vendor libs are loaded directly into the 'vendor' bundle (through require() calls in vendor.js). + // This ensures that any further require() calls in other bundles aren't duplicating libs. + new webpack.optimize.CommonsChunkPlugin({ + name: 'vendor', + minChunks: Infinity, + }), + ]; + + for (var i = 0; i < Config.length; i++) { + Config[i].devtool = 'source-map'; + } +} + +module.exports = Config; diff --git a/webpack.config.js b/webpack.config.js index e7163883a..3a1b318b0 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -88,7 +88,6 @@ const config = [ config: 'Config', 'lib/Router': 'Router', }, - devtool: 'source-map', module: { loaders: [ { @@ -152,7 +151,6 @@ const config = [ path: 'admin/client/dist', filename: '[name].css', }, - devtool: 'source-map', module: { loaders: [ { @@ -202,7 +200,6 @@ const config = [ path: './', filename: '[name].css', }, - devtool: 'source-map', module: { loaders: [ {