diff --git a/package.json b/package.json index 57636221c..439bc6d7b 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..b45ec6c19 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,6 +1,7 @@ const webpack = require('webpack'); const autoprefixer = require('autoprefixer'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); +const path = require('path'); // const SprityWebpackPlugin = require('sprity-webpack-plugin'); const PATHS = { @@ -48,7 +49,8 @@ const config = [ TinyMCE_SSPlugin: `${PATHS.ADMIN_JS_SRC}/legacy/TinyMCE_SSPlugin.js`, }, resolve: { - modulesDirectories: [PATHS.ADMIN_JS_SRC, PATHS.MODULES], + root: [__dirname, path.resolve(__dirname, PATHS.ADMIN_JS_SRC)], + modulesDirectories: [PATHS.MODULES], }, output: { path: 'admin/client/dist', @@ -88,7 +90,6 @@ const config = [ config: 'Config', 'lib/Router': 'Router', }, - devtool: 'source-map', module: { loaders: [ { @@ -152,7 +153,6 @@ const config = [ path: 'admin/client/dist', filename: '[name].css', }, - devtool: 'source-map', module: { loaders: [ { @@ -202,7 +202,6 @@ const config = [ path: './', filename: '[name].css', }, - devtool: 'source-map', module: { loaders: [ {