mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 02:54:11 +08:00
feat: initial angular support + clean up tests
This commit is contained in:
@ -1,10 +1,48 @@
|
||||
import Config from 'webpack-chain';
|
||||
import path from 'path';
|
||||
|
||||
import { IWebpackEnv } from '../index';
|
||||
import { getEntryPath, getProjectRootPath } from '../helpers/project';
|
||||
import { env as _env, IWebpackEnv } from '../index';
|
||||
import base from './base';
|
||||
|
||||
export default function (config: Config, env: IWebpackEnv): Config {
|
||||
export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
base(config, env);
|
||||
|
||||
const tsConfigPath = path.join(getProjectRootPath(), 'tsconfig.json');
|
||||
|
||||
// remove default ts rule
|
||||
config.module.rules.delete('ts');
|
||||
|
||||
config.module
|
||||
.rule('angular')
|
||||
.test(/(?:\.ngfactory.js|\.ngstyle\.js|\.ts)$/)
|
||||
.use('@ngtools/webpack')
|
||||
.loader('@ngtools/webpack');
|
||||
|
||||
config.module
|
||||
.rule('@angular/core')
|
||||
.test(/[\/\\]@angular[\/\\]core[\/\\].+\.js$/)
|
||||
.parser({ system: true });
|
||||
|
||||
// set up html
|
||||
config.module
|
||||
.rule('html')
|
||||
.test(/\.html$/)
|
||||
.use('raw-loader')
|
||||
.loader('raw-loader');
|
||||
|
||||
config.plugin('AngularCompilerPlugin').use(getAngularCompilerPlugin(), [
|
||||
{
|
||||
tsConfigPath,
|
||||
mainPath: getEntryPath(),
|
||||
platformTransformers: [require('../transformers/NativeClass').default],
|
||||
},
|
||||
]);
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
function getAngularCompilerPlugin() {
|
||||
const { AngularCompilerPlugin } = require('@ngtools/webpack');
|
||||
return AngularCompilerPlugin;
|
||||
}
|
||||
|
Reference in New Issue
Block a user