about summary refs log tree commit diff
path: root/config/webpack/loaders/babel_external.js
blob: 39e74ed90a5eec9ed4ef17c45a2557ff93e81380 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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'),
    },
  };
}