Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Don't use babel-loader's cacheDirectory for production #516

Merged
merged 1 commit into from
Mar 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/loaders/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ module.exports = {
getLoaders(webpackConfig) {
let babelConfig = {
// improves performance by caching babel compiles
// we add this option ALWAYS
// this option is always added but is set to FALSE in
// production to avoid cache invalidation issues caused
// by some Babel presets/plugins (for instance the ones
// that use browserslist)
// https://github.com/babel/babel-loader#options
cacheDirectory: true
cacheDirectory: !webpackConfig.isProduction()
};

// configure babel (unless the user is specifying .babelrc)
Expand Down
12 changes: 12 additions & 0 deletions test/loaders/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ describe('loaders/babel', () => {
});
});

it('getLoaders() for production', () => {
const config = createConfig();
config.runtimeConfig.babelRcFileExists = true;
config.runtimeConfig.environment = 'production';

const actualLoaders = babelLoader.getLoaders(config);
// cacheDirectory is disabled in production mode
expect(actualLoaders[0].options).to.deep.equal({
cacheDirectory: false
});
});

it('getLoaders() with react', () => {
const config = createConfig();
config.enableReactPreset();
Expand Down