feat: initial angular support + clean up tests

This commit is contained in:
Igor Randjelovic
2020-11-25 17:44:00 +01:00
parent 015d337e2a
commit d9a93040fe
17 changed files with 651 additions and 48 deletions

View File

@ -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;
}