mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
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:
@ -198,12 +198,24 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
.options({
|
||||
platform,
|
||||
})
|
||||
.end()
|
||||
.use('nativescript-hot-loader')
|
||||
.loader('nativescript-hot-loader')
|
||||
.options({
|
||||
injectHMRRuntime: true,
|
||||
});
|
||||
.end();
|
||||
|
||||
config.when(env.hmr, (config) => {
|
||||
config.module
|
||||
.rule('bundle')
|
||||
.use('nativescript-hot-loader')
|
||||
.loader('nativescript-hot-loader')
|
||||
.options({
|
||||
injectHMRRuntime: true,
|
||||
});
|
||||
});
|
||||
|
||||
// worker-loader should be declared before ts-loader
|
||||
config.module
|
||||
.rule('workers')
|
||||
.test(/\.(js|ts)$/)
|
||||
.use('nativescript-worker-loader')
|
||||
.loader('nativescript-worker-loader');
|
||||
|
||||
// set up ts support
|
||||
config.module
|
||||
@ -249,12 +261,6 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
.exclude.add(/node_modules/)
|
||||
.end();
|
||||
|
||||
config.module
|
||||
.rule('workers')
|
||||
.test(/\.(js|ts)$/)
|
||||
.use('nativescript-worker-loader')
|
||||
.loader('nativescript-worker-loader');
|
||||
|
||||
// config.resolve.extensions.add('.xml');
|
||||
// set up xml
|
||||
config.module
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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|ts)$/)
|
||||
.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('ts')
|
||||
.test(/\.(js|ts)$/)
|
||||
.exclude.add(/node_modules/)
|
||||
.add(entryPath)
|
||||
.end()
|
||||
.use('nativescript-hot-loader')
|
||||
.loader('nativescript-hot-loader')
|
||||
.options({
|
||||
appPath: getEntryDirPath(),
|
||||
});
|
||||
});
|
||||
|
||||
return config;
|
||||
}
|
||||
|
Reference in New Issue
Block a user