fix(webpack5): include hmr handling only when enabled (#9685)

* fix(webpack): respect hmr flag

* fix(webpack): ensure correct loader order is used

* chore: cleanup

Co-authored-by: Igor Randjelovic <rigor789@gmail.com>
This commit is contained in:
Eduardo Speroni
2021-11-29 13:55:10 -03:00
committed by GitHub
parent 57eac49128
commit 05082b1aec
10 changed files with 190 additions and 344 deletions

View File

@@ -34,18 +34,21 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
virtualEntryPath
);
// set up core HMR
config.module
.rule('hmr-core')
.test(/\.js$/)
.exclude.add(/node_modules/)
.add(entryPath)
.end()
.use('nativescript-hot-loader')
.loader('nativescript-hot-loader')
.options({
appPath: getEntryDirPath(),
});
config.when(env.hmr, (config) => {
// set up core HMR
config.module
.rule('hmr-core')
.before('js')
.test(/\.js$/)
.exclude.add(/node_modules/)
.add(entryPath)
.end()
.use('nativescript-hot-loader')
.loader('nativescript-hot-loader')
.options({
appPath: getEntryDirPath(),
});
});
return config;
}