File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -20,9 +20,12 @@ module.exports = {
2020 getLoaders ( webpackConfig ) {
2121 let babelConfig = {
2222 // improves performance by caching babel compiles
23- // we add this option ALWAYS
23+ // this option is always added but is set to FALSE in
24+ // production to avoid cache invalidation issues caused
25+ // by some Babel presets/plugins (for instance the ones
26+ // that use browserslist)
2427 // https://github.com/babel/babel-loader#options
25- cacheDirectory : true
28+ cacheDirectory : ! webpackConfig . isProduction ( )
2629 } ;
2730
2831 // configure babel (unless the user is specifying .babelrc)
Original file line number Diff line number Diff line change @@ -49,6 +49,18 @@ describe('loaders/babel', () => {
4949 } ) ;
5050 } ) ;
5151
52+ it ( 'getLoaders() for production' , ( ) => {
53+ const config = createConfig ( ) ;
54+ config . runtimeConfig . babelRcFileExists = true ;
55+ config . runtimeConfig . environment = 'production' ;
56+
57+ const actualLoaders = babelLoader . getLoaders ( config ) ;
58+ // cacheDirectory is disabled in production mode
59+ expect ( actualLoaders [ 0 ] . options ) . to . deep . equal ( {
60+ cacheDirectory : false
61+ } ) ;
62+ } ) ;
63+
5264 it ( 'getLoaders() with react' , ( ) => {
5365 const config = createConfig ( ) ;
5466 config . enableReactPreset ( ) ;
You can’t perform that action at this time.
0 commit comments