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 = {
20
20
getLoaders ( webpackConfig ) {
21
21
let babelConfig = {
22
22
// 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)
24
27
// https://github.com/babel/babel-loader#options
25
- cacheDirectory : true
28
+ cacheDirectory : ! webpackConfig . isProduction ( )
26
29
} ;
27
30
28
31
// 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', () => {
49
49
} ) ;
50
50
} ) ;
51
51
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
+
52
64
it ( 'getLoaders() with react' , ( ) => {
53
65
const config = createConfig ( ) ;
54
66
config . enableReactPreset ( ) ;
You can’t perform that action at this time.
0 commit comments