mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat: core-hmr handling & watch ignore
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { DefinePlugin, HotModuleReplacementPlugin } from 'webpack';
|
||||
import Config from 'webpack-chain';
|
||||
import { resolve } from 'path';
|
||||
import os from 'os';
|
||||
|
||||
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
|
||||
import FilterWarningsPlugin from 'webpack-filter-warnings-plugin';
|
||||
@@ -9,10 +8,10 @@ import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
|
||||
import TerserPlugin from 'terser-webpack-plugin';
|
||||
|
||||
// import { WatchStateLoggerPlugin } from '../plugins/WatchStateLoggerPlugin';
|
||||
import { getProjectFilePath, getProjectRootPath } from '../helpers/project';
|
||||
import { PlatformSuffixPlugin } from '../plugins/PlatformSuffixPlugin';
|
||||
import { addCopyRule, applyCopyRules } from '../helpers/copyRules';
|
||||
import { WatchStatePlugin } from '../plugins/WatchStatePlugin';
|
||||
import { getProjectRootPath } from '../helpers/project';
|
||||
import { hasDependency } from '../helpers/dependencies';
|
||||
import { applyDotEnvPlugin } from '../helpers/dotEnv';
|
||||
import { env as _env, IWebpackEnv } from '../index';
|
||||
@@ -80,6 +79,13 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
.globalObject('global')
|
||||
.set('clean', true);
|
||||
|
||||
config.watchOptions({
|
||||
ignored: [
|
||||
`${getProjectFilePath('platforms')}/platforms/**`,
|
||||
`${env.appResourcesPath ?? getProjectFilePath('App_Resources')}/**`
|
||||
]
|
||||
})
|
||||
|
||||
// Set up Terser options
|
||||
config.optimization.minimizer('TerserPlugin').use(TerserPlugin, [
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import Config from 'webpack-chain';
|
||||
|
||||
import { addVirtualEntry } from '../helpers/virtualModules';
|
||||
import { getEntryDirPath } from "../helpers/platform";
|
||||
import { env as _env, IWebpackEnv } from '../index';
|
||||
import base from './base';
|
||||
|
||||
@@ -31,5 +32,18 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
.use('xml-namespace-loader')
|
||||
.loader('xml-namespace-loader');
|
||||
|
||||
// set up core HMR
|
||||
config.module
|
||||
.rule('hmr-core')
|
||||
.test(/\.js$/)
|
||||
.exclude
|
||||
.add(/node_modules/)
|
||||
.end()
|
||||
.use('nativescript-hot-loader')
|
||||
.loader('nativescript-hot-loader')
|
||||
.options({
|
||||
appPath: getEntryDirPath()
|
||||
})
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import Config from 'webpack-chain';
|
||||
|
||||
import { addVirtualEntry } from '../helpers/virtualModules';
|
||||
import { getEntryDirPath } from "../helpers/platform";
|
||||
import { env as _env, IWebpackEnv } from '../index';
|
||||
import base from './base';
|
||||
|
||||
@@ -31,5 +32,18 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
.use('xml-namespace-loader')
|
||||
.loader('xml-namespace-loader');
|
||||
|
||||
// set up core HMR
|
||||
config.module
|
||||
.rule('hmr-core')
|
||||
.test(/\.(js|ts)$/)
|
||||
.exclude
|
||||
.add(/node_modules/)
|
||||
.end()
|
||||
.use('nativescript-hot-loader')
|
||||
.loader('nativescript-hot-loader')
|
||||
.options({
|
||||
appPath: getEntryDirPath()
|
||||
})
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user