@@ -57,6 +57,9 @@ const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
5757// Some apps do not need the benefits of saving a web request, so not inlining the chunk
5858// makes for a smoother build process.
5959const shouldInlineRuntimeChunk = process . env . INLINE_RUNTIME_CHUNK !== 'false' ;
60+ // We might not want to use the hard source plugin on environments that won't persist the cache for later
61+ const useHardSourceWebpackPlugin =
62+ process . env . USE_HARD_SOURCE_WEBPACK_PLUGIN === 'true' ;
6063
6164// Check if TypeScript is setup
6265const useTypeScript = fs . existsSync ( paths . appTsConfig ) ;
@@ -283,11 +286,13 @@ module.exports = function(webpackEnv) {
283286 ? {
284287 chunks : 'all' ,
285288 name : false ,
286- cacheGroups : bpkReactScriptsConfig . vendorsChunkRegex ? {
287- vendors : {
288- test : new RegExp ( bpkReactScriptsConfig . vendorsChunkRegex ) ,
289- } ,
290- } : { } ,
289+ cacheGroups : bpkReactScriptsConfig . vendorsChunkRegex
290+ ? {
291+ vendors : {
292+ test : new RegExp ( bpkReactScriptsConfig . vendorsChunkRegex ) ,
293+ } ,
294+ }
295+ : { } ,
291296 }
292297 : { } ,
293298 // Keep the runtime chunk seperated to enable long term caching
@@ -605,17 +610,18 @@ module.exports = function(webpackEnv) {
605610 ] ,
606611 } ,
607612 plugins : [
608- new HardSourceWebpackPlugin ( ) ,
609- new HardSourceWebpackPlugin . ExcludeModulePlugin ( [
610- {
613+ useHardSourceWebpackPlugin && new HardSourceWebpackPlugin ( ) ,
614+ useHardSourceWebpackPlugin &&
615+ new HardSourceWebpackPlugin . ExcludeModulePlugin ( [
616+ {
611617 // HardSource works with mini-css-extract-plugin but due to how
612618 // mini-css emits assets, assets are not emitted on repeated builds with
613619 // mini-css and hard-source together. Ignoring the mini-css loader
614620 // modules, but not the other css loader modules, excludes the modules
615621 // that mini-css needs rebuilt to output assets every time.
616622 test : / m i n i - c s s - e x t r a c t - p l u g i n [ \\ / ] d i s t [ \\ / ] l o a d e r / ,
617- } ,
618- ] ) ,
623+ } ,
624+ ] ) ,
619625 new LoadablePlugin ( ) ,
620626 // Generates an `index.html` file with the <script> injected.
621627 new HtmlWebpackPlugin (
0 commit comments