mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import Config from 'webpack-chain';
|
|
|
|
import { getEntryPath, getEntryDirPath } from '../helpers/platform';
|
|
import { chainedSetAddAfter } from '../helpers/chain';
|
|
import { env as _env, IWebpackEnv } from '../index';
|
|
import { ContextExclusionPlugin } from 'webpack';
|
|
import base from './base';
|
|
import path from 'path';
|
|
|
|
export default function (config: Config, env: IWebpackEnv = _env): Config {
|
|
base(config, env);
|
|
const entryPath = getEntryPath();
|
|
const virtualEntryPath = path.resolve(
|
|
__dirname,
|
|
'../stubs/virtual-entry-javascript'
|
|
);
|
|
|
|
// exclude files starting with _ from require.context
|
|
config
|
|
.plugin(`ContextExclusionPlugin|exclude_files`)
|
|
.use(ContextExclusionPlugin, [/\b_.+\./]);
|
|
|
|
chainedSetAddAfter(
|
|
config.entry('bundle'),
|
|
'@nativescript/core/globals/index',
|
|
virtualEntryPath
|
|
);
|
|
|
|
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;
|
|
}
|