about summary refs log tree commit diff
path: root/config/webpack
diff options
context:
space:
mode:
authorkibigo! <marrus-sh@users.noreply.github.com>2017-10-11 10:43:10 -0700
committerkibigo! <marrus-sh@users.noreply.github.com>2017-10-11 10:43:10 -0700
commit8d6b9ba4946b5b159af0fbd130637a226a286796 (patch)
tree9def26711682d29338cfa1b081822029a01669eb /config/webpack
parentf0a2a6c875e9294f0ea1d4c6bc90529e41a2dc37 (diff)
parent476e79b8e340c9103352a0799e102e4aca1a5593 (diff)
Merge upstream 2.0ish #165
Diffstat (limited to 'config/webpack')
-rw-r--r--config/webpack/development.js15
-rw-r--r--config/webpack/loaders/babel.js6
-rw-r--r--config/webpack/loaders/babel_external.js21
-rw-r--r--config/webpack/shared.js7
4 files changed, 41 insertions, 8 deletions
diff --git a/config/webpack/development.js b/config/webpack/development.js
index 830183c0d..12670f5cd 100644
--- a/config/webpack/development.js
+++ b/config/webpack/development.js
@@ -4,6 +4,17 @@ const merge = require('webpack-merge');
 const sharedConfig = require('./shared.js');
 const { settings, output } = require('./configuration.js');
 
+const watchOptions = {
+  ignored: /node_modules/,
+};
+
+if (process.env.VAGRANT) {
+  // If we are in Vagrant, we can't rely on inotify to update us with changed
+  // files, so we must poll instead. Here, we poll every second to see if
+  // anything has changed.
+  watchOptions.poll = 1000;
+}
+
 module.exports = merge(sharedConfig, {
   devtool: 'cheap-module-eval-source-map',
 
@@ -26,8 +37,6 @@ module.exports = merge(sharedConfig, {
     headers: { 'Access-Control-Allow-Origin': '*' },
     historyApiFallback: true,
     disableHostCheck: true,
-    watchOptions: {
-      ignored: /node_modules/,
-    },
+    watchOptions: watchOptions,
   },
 });
diff --git a/config/webpack/loaders/babel.js b/config/webpack/loaders/babel.js
index 989a87dcf..770c89aa7 100644
--- a/config/webpack/loaders/babel.js
+++ b/config/webpack/loaders/babel.js
@@ -4,11 +4,7 @@ const env = process.env.NODE_ENV || 'development';
 
 module.exports = {
   test: /\.js$/,
-  // include react-intl because transform-react-remove-prop-types needs to apply to it
-  exclude: {
-    test: /node_modules/,
-    exclude: /react-intl[\/\\](?!locale-data)/,
-  },
+  exclude: /node_modules/,
   loader: 'babel-loader',
   options: {
     forceEnv: process.env.NODE_ENV || 'development',
diff --git a/config/webpack/loaders/babel_external.js b/config/webpack/loaders/babel_external.js
new file mode 100644
index 000000000..39e74ed90
--- /dev/null
+++ b/config/webpack/loaders/babel_external.js
@@ -0,0 +1,21 @@
+const { resolve } = require('path');
+
+const env = process.env.NODE_ENV || 'development';
+
+if (env === 'development') {
+  module.exports = {};
+} else {
+  // babel options to apply only to external libraries, e.g. remove-prop-types
+  module.exports = {
+    test: /\.js$/,
+    include: /node_modules/,
+    loader: 'babel-loader',
+    options: {
+      babelrc: false,
+      plugins: [
+        'transform-react-remove-prop-types',
+      ],
+      cacheDirectory: env === 'development' ? false : resolve(__dirname, '..', '..', '..', 'tmp', 'cache', 'babel-loader-external'),
+    },
+  };
+}
diff --git a/config/webpack/shared.js b/config/webpack/shared.js
index 99f4dec1a..e3a1fc379 100644
--- a/config/webpack/shared.js
+++ b/config/webpack/shared.js
@@ -50,6 +50,13 @@ module.exports = {
 
   plugins: [
     new webpack.EnvironmentPlugin(JSON.parse(JSON.stringify(env))),
+    new webpack.NormalModuleReplacementPlugin(
+      /^history\//, (resource) => {
+        // temporary fix for https://github.com/ReactTraining/react-router/issues/5576
+        // to reduce bundle size
+        resource.request = resource.request.replace(/^history/, 'history/es');
+      }
+    ),
     new ExtractTextPlugin({
       filename: env.NODE_ENV === 'production' ? '[name]-[hash].css' : '[name].css',
       allChunks: true,