mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat: add entryDir helper + update aliases
This commit is contained in:
@@ -13,6 +13,7 @@ import { WatchStatePlugin } from '../plugins/WatchStatePlugin';
|
||||
import { IWebpackEnv } from '../index';
|
||||
import {
|
||||
getAbsoluteDistPath,
|
||||
getEntryDirPath,
|
||||
getEntryPath,
|
||||
getPlatform,
|
||||
} from '../helpers/project';
|
||||
@@ -106,9 +107,7 @@ export default function (config: Config, env: IWebpackEnv): Config {
|
||||
.add('.json');
|
||||
|
||||
// base aliases
|
||||
config.resolve.alias
|
||||
.set('~', '<TODO>appFullPath')
|
||||
.set('@', '<TODO>appFullPath');
|
||||
config.resolve.alias.set('~', getEntryDirPath()).set('@', getEntryDirPath());
|
||||
|
||||
// resolve symlinks
|
||||
config.resolve.symlinks(true);
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
import VirtualModulesPlugin from 'webpack-virtual-modules';
|
||||
import Config from 'webpack-chain';
|
||||
|
||||
import { getEntryPath } from '../helpers/project';
|
||||
import { IWebpackEnv } from '../index';
|
||||
import base from './base';
|
||||
import dedent from 'ts-dedent';
|
||||
import { join } from 'path';
|
||||
|
||||
// todo: add base configuration for core with javascript
|
||||
export default function (config: Config, env: IWebpackEnv): Config {
|
||||
import { env as _env, IWebpackEnv } from '../index';
|
||||
import { getEntryDirPath } from '../helpers/project';
|
||||
import base from './base';
|
||||
|
||||
export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
base(config, env);
|
||||
|
||||
const virtualEntryPath = getEntryPath() + '.virtual.js';
|
||||
const virtualEntryPath = join(getEntryDirPath(), '__virtual_entry__.js');
|
||||
const filterRE = '/.(xml|js|s?css)$/';
|
||||
|
||||
config.entry('bundle').add(virtualEntryPath);
|
||||
|
||||
@@ -18,11 +19,10 @@ export default function (config: Config, env: IWebpackEnv): Config {
|
||||
config.plugin('VirtualModulesPlugin').use(VirtualModulesPlugin, [
|
||||
{
|
||||
[virtualEntryPath]: dedent`
|
||||
require('@nativescript/core/bundle-entry-points')
|
||||
|
||||
const context = require.context("./", /* deep: */ true);
|
||||
global.registerWebpackModules(context);
|
||||
`,
|
||||
require('@nativescript/core/bundle-entry-points')
|
||||
const context = require.context("~/", /* deep: */ true, /* filter: */ ${filterRE});
|
||||
global.registerWebpackModules(context);
|
||||
`,
|
||||
},
|
||||
]);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { env, Platform } from '../index';
|
||||
import { resolve, basename } from 'path';
|
||||
import { resolve, basename, dirname } from 'path';
|
||||
import { error } from './log';
|
||||
|
||||
export function getProjectRootPath(): string {
|
||||
@@ -19,6 +19,10 @@ export function getEntryPath() {
|
||||
return resolve(getProjectRootPath(), packageJson.main);
|
||||
}
|
||||
|
||||
export function getEntryDirPath() {
|
||||
return dirname(getEntryPath());
|
||||
}
|
||||
|
||||
export function getDistPath() {
|
||||
if (env.ios) {
|
||||
const appName = basename(getProjectRootPath());
|
||||
|
||||
Reference in New Issue
Block a user