mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat: angular 12 support
This commit is contained in:
@@ -84,37 +84,49 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
|||||||
.use('sass-loader')
|
.use('sass-loader')
|
||||||
.loader('sass-loader');
|
.loader('sass-loader');
|
||||||
|
|
||||||
config.plugin('AngularCompilerPlugin').use(getAngularCompilerPlugin(), [
|
const angularCompilerPlugin = getAngularCompilerPlugin();
|
||||||
{
|
if (angularCompilerPlugin) {
|
||||||
tsConfigPath,
|
config.plugin('AngularCompilerPlugin').use(angularCompilerPlugin, [
|
||||||
mainPath: getEntryPath(),
|
{
|
||||||
// disable type checking in a forked process - it ignores
|
tsConfigPath,
|
||||||
// the hostReplacementPaths and prints errors about
|
mainPath: getEntryPath(),
|
||||||
// platform suffixed files, even though they are
|
// disable type checking in a forked process - it ignores
|
||||||
// working as expected.
|
// the hostReplacementPaths and prints errors about
|
||||||
forkTypeChecker: false,
|
// platform suffixed files, even though they are
|
||||||
hostReplacementPaths(path: string) {
|
// working as expected.
|
||||||
const ext = extname(path);
|
forkTypeChecker: false,
|
||||||
const platformExt = `.${platform}${ext}`;
|
hostReplacementPaths(path: string) {
|
||||||
|
const ext = extname(path);
|
||||||
|
const platformExt = `.${platform}${ext}`;
|
||||||
|
|
||||||
// already includes a platform specific extension - ignore
|
// already includes a platform specific extension - ignore
|
||||||
if (path.includes(platformExt)) {
|
if (path.includes(platformExt)) {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
const platformPath = path.replace(ext, platformExt);
|
||||||
|
// check if the same file exists with a platform suffix and return if it does.
|
||||||
|
if (existsSync(platformPath)) {
|
||||||
|
// console.log(`[hostReplacementPaths] resolving "${path}" to "${platformPath}"`);
|
||||||
|
return platformPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
// just return the original path otherwise
|
||||||
return path;
|
return path;
|
||||||
}
|
},
|
||||||
|
platformTransformers: [require('../transformers/NativeClass').default],
|
||||||
const platformPath = path.replace(ext, platformExt);
|
|
||||||
// check if the same file exists with a platform suffix and return if it does.
|
|
||||||
if (existsSync(platformPath)) {
|
|
||||||
// console.log(`[hostReplacementPaths] resolving "${path}" to "${platformPath}"`);
|
|
||||||
return platformPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
// just return the original path otherwise
|
|
||||||
return path;
|
|
||||||
},
|
},
|
||||||
platformTransformers: [require('../transformers/NativeClass').default],
|
]);
|
||||||
},
|
}
|
||||||
]);
|
|
||||||
|
const angularWebpackPlugin = getAngularWebpackPlugin();
|
||||||
|
if (angularWebpackPlugin) {
|
||||||
|
config.plugin('AngularWebpackPlugin').use(angularWebpackPlugin, [
|
||||||
|
{
|
||||||
|
tsconfig: tsConfigPath,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
// Filter common undesirable warnings
|
// Filter common undesirable warnings
|
||||||
config.set(
|
config.set(
|
||||||
@@ -147,3 +159,8 @@ function getAngularCompilerPlugin(): any {
|
|||||||
const { AngularCompilerPlugin } = require('@ngtools/webpack');
|
const { AngularCompilerPlugin } = require('@ngtools/webpack');
|
||||||
return AngularCompilerPlugin;
|
return AngularCompilerPlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getAngularWebpackPlugin(): any {
|
||||||
|
const { AngularWebpackPlugin } = require('@ngtools/webpack');
|
||||||
|
return AngularWebpackPlugin;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user