mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 11:01:21 +08:00
feat(webpack5): support for angular polyfills.ts
This commit is contained in:
@ -1,8 +1,12 @@
|
|||||||
import Config from 'webpack-chain';
|
import Config from 'webpack-chain';
|
||||||
import { existsSync } from 'fs';
|
import { existsSync } from 'fs';
|
||||||
import { extname } from 'path';
|
import { extname, join } from 'path';
|
||||||
|
|
||||||
import { getEntryPath, getPlatformName } from '../helpers/platform';
|
import {
|
||||||
|
getEntryDirPath,
|
||||||
|
getEntryPath,
|
||||||
|
getPlatformName,
|
||||||
|
} from '../helpers/platform';
|
||||||
import { getProjectFilePath } from '../helpers/project';
|
import { getProjectFilePath } from '../helpers/project';
|
||||||
import { env as _env, IWebpackEnv } from '../index';
|
import { env as _env, IWebpackEnv } from '../index';
|
||||||
import base from './base';
|
import base from './base';
|
||||||
@ -128,6 +132,22 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getPolyfillPath = (platform?: string) =>
|
||||||
|
join(getEntryDirPath(), `polyfills${platform ? '.' + platform : ''}.ts`);
|
||||||
|
const polyfillsPath = getPolyfillPath();
|
||||||
|
const polyfillsPathResolved = [
|
||||||
|
polyfillsPath,
|
||||||
|
getPolyfillPath('android'),
|
||||||
|
getPolyfillPath('ios'),
|
||||||
|
];
|
||||||
|
if (polyfillsPathResolved.find(existsSync)) {
|
||||||
|
let entries = config.entry('bundle').values();
|
||||||
|
entries = entries.map((v) =>
|
||||||
|
v === '@nativescript/core/globals/index.js' ? polyfillsPath : v
|
||||||
|
);
|
||||||
|
config.entry('bundle').clear().merge(entries);
|
||||||
|
}
|
||||||
|
|
||||||
// Filter common undesirable warnings
|
// Filter common undesirable warnings
|
||||||
config.set(
|
config.set(
|
||||||
'ignoreWarnings',
|
'ignoreWarnings',
|
||||||
|
Reference in New Issue
Block a user