[6.x] Avoid unnecessary recompile at startup (#20176) (#20279)

Backports the following commits to 6.x:
 - Avoid unnecessary recompile at startup  (#20176)
This commit is contained in:
Spencer 2018-06-27 17:01:51 -07:00 committed by GitHub
parent e75423e020
commit 73718c54fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -337,6 +337,19 @@ export default class BaseOptimizer {
}
};
const watchingConfig = {
plugins: [
new webpack.WatchIgnorePlugin([
// When our bundle entry files are fresh they cause webpack
// to think they might have changed since the watcher was
// initialized, which triggers a second compilation on startup.
// Since we can't reliably update these files anyway, we can
// just ignore them in the watcher and prevent the extra compilation
/bundles[\/\\].+\.entry\.js/,
])
]
};
// in production we set the process.env.NODE_ENV and uglify our bundles
const productionConfig = {
plugins: [
@ -361,7 +374,7 @@ export default class BaseOptimizer {
? {}
: transpileTsConfig,
this.uiBundles.isDevMode()
? supportEnzymeConfig
? webpackMerge(watchingConfig, supportEnzymeConfig)
: productionConfig
);
}