about summary refs log tree commit diff
path: root/config/webpack/loaders/babel_external.js
diff options
context:
space:
mode:
authorNolan Lawson <nolan@nolanlawson.com>2017-10-10 09:44:51 -0700
committerEugen Rochko <eugen@zeonfederated.com>2017-10-10 18:44:51 +0200
commitbebaa6eced0af2665d105beb59bd21030425245a (patch)
tree9c88ae0b8630396cc23efcb63a5b8ec7e77364bc /config/webpack/loaders/babel_external.js
parent616f53eea81ba23d824744119aeed7cf4d22a03b (diff)
Remove prop types from external libraries (#5304)
Diffstat (limited to 'config/webpack/loaders/babel_external.js')
-rw-r--r--config/webpack/loaders/babel_external.js21
1 files changed, 21 insertions, 0 deletions
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'),
+    },
+  };
+}