mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat: platform suffix resolution [wip]
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
||||
getPlatform,
|
||||
} from '../helpers/project';
|
||||
import { hasDependency } from '../helpers/dependencies';
|
||||
import { PlatformSuffixPlugin } from '../plugins/PlatformSuffixPlugin';
|
||||
|
||||
export default function (config: Config, env: IWebpackEnv): Config {
|
||||
const entryPath = getEntryPath();
|
||||
@@ -28,6 +29,10 @@ export default function (config: Config, env: IWebpackEnv): Config {
|
||||
// set mode
|
||||
config.mode(mode);
|
||||
|
||||
// config.stats({
|
||||
// logging: 'verbose'
|
||||
// })
|
||||
|
||||
// package.json is generated by the CLI with runtime options
|
||||
// this ensures it's not included in the bundle, but rather
|
||||
// resolved at runtime
|
||||
@@ -194,6 +199,22 @@ export default function (config: Config, env: IWebpackEnv): Config {
|
||||
},
|
||||
]);
|
||||
|
||||
// config.plugin('NormalModuleReplacementPlugin').use(NormalModuleReplacementPlugin, [
|
||||
// /.*/,
|
||||
// request => {
|
||||
// if (new RegExp(`\.${platform}\..+$`).test(request.request)) {
|
||||
// request.rawRequest = request.rawRequest.replace(`.${platform}.`, '.')
|
||||
// console.log(request)
|
||||
// }
|
||||
// }
|
||||
// ])
|
||||
|
||||
config.plugin('PlatformSuffixPlugin').use(PlatformSuffixPlugin, [
|
||||
{
|
||||
platform,
|
||||
},
|
||||
]);
|
||||
|
||||
// todo: refine defaults
|
||||
config.plugin('DefinePlugin').use(DefinePlugin, [
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import VirtualModulesPlugin from 'webpack-virtual-modules';
|
||||
import { ContextExclusionPlugin } from 'webpack';
|
||||
import Config from 'webpack-chain';
|
||||
import dedent from 'ts-dedent';
|
||||
import { join } from 'path';
|
||||
@@ -15,7 +16,12 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
|
||||
config.entry('bundle').add(virtualEntryPath);
|
||||
|
||||
// Add a virtual entry module
|
||||
config
|
||||
.plugin('ContextExclusionPluginPlugin')
|
||||
.use(ContextExclusionPlugin, [/__virtual_entry__\.js$/]);
|
||||
|
||||
// Add a virtual entry module that will register all modules into
|
||||
// the nativescript module loader/handler
|
||||
config.plugin('VirtualModulesPlugin').use(VirtualModulesPlugin, [
|
||||
{
|
||||
[virtualEntryPath]: dedent`
|
||||
@@ -26,6 +32,8 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
},
|
||||
]);
|
||||
|
||||
config.resolve.extensions.add('.xml');
|
||||
|
||||
// set up xml
|
||||
config.module
|
||||
.rule('xml')
|
||||
|
||||
Reference in New Issue
Block a user