Skip to content

Commit

Permalink
Scripts: Use cache directory for Babel loader
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Apr 7, 2019
1 parent b5adcb9 commit 294c42e
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions packages/scripts/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ const externals = [
const isProduction = process.env.NODE_ENV === 'production';
const mode = isProduction ? 'production' : 'development';

const getBabelLoaderOptions = () => hasBabelConfig() ? {} : {
babelrc: false,
configFile: false,
presets: [ require.resolve( '@wordpress/babel-preset-default' ) ],
};

const config = {
mode,
entry: {
Expand Down Expand Up @@ -103,7 +97,20 @@ const config = {
'thread-loader',
{
loader: require.resolve( 'babel-loader' ),
options: getBabelLoaderOptions(),
options: {
// Babel uses a directory within local node_modules
// by default. Use the environment variable option
// to enable more persistent caching.
cacheDirectory: process.env.BABEL_CACHE_DIRECTORY || true,

// Provide a fallback configuration if there's not
// one explicitly available in the project.
...( ! hasBabelConfig() && {
babelrc: false,
configFile: false,
presets: [ require.resolve( '@wordpress/babel-preset-default' ) ],
} ),
},
},
],
},
Expand Down

0 comments on commit 294c42e

Please sign in to comment.