我正在尝试在我的angular / webpack应用程序上实现ngc编译配置。我在我的根文件夹中有一个tsConfig-aot.json,如下所示。
{
....
"files": [
"src/app/app.module.ts",
"src/app/lazy/about/about.module.ts",
"src/app/lazy/employees/employees.module.ts",
"src/app/lazy/login/login.module.ts",
"src/app/lazy/employee-details/employee-details.module.ts"
],
"include": [
"src/polyfills.ts",
"src/vendor.ts"
],
"exclude": [
"./node_modules",
"./**/*.e2e.ts",
"./**/*.spec.ts",
"./src/main-aot.ts"
],
"angularCompilerOptions": {
"genDir": "./aot",
"skipMetadataEmit": true
}
}
我的webpack配置如下。
module.exports = {
entry: {
'polyfills': './src/polyfills.ts',
'vendor': './src/vendor.ts',
'app': './src/main-aot.ts'
},
resolve: {
extensions: ['.ts', '.js']
},
module: {
rules: [
{
test: /\.ts$/,
loaders: [
{
loader: '@ngtools/webpack',
options: { configFileName: helpers.root('tsconfig-aot.json') }
}, 'angular-router-loader?aot=true&genDir=aot/', 'angular2-template-loader'
],
exclude: [/node_modules/, /\.(spec|e2e)\.ts$/]
},
]
},
plugins: [
new AngularCompilerPlugin({
tsConfigPath: 'tsconfig-aot.json',
sourceMap: true
}),
new webpack.optimize.CommonsChunkPlugin({
names: ['app', 'vendor', 'polyfills']
}),
...
]
};
我正在尝试为我的应用实现aot build config。但是,当我运行./node_modules/.bin/ngc -p ./tsconfig-aot.json
时。我的应用编译失败,错误说明
TypeScript编译中缺少src / main-aot
我的主要内容如下:
import { platformBrowser } from '@angular/platform-browser';
import { enableProdMode } from '@angular/core';
import { AppModuleNgFactory } from '../aot/src/app/app.module.ngfactory';
enableProdMode();
platformBrowser().bootstrapModuleFactory(AppModuleNgFactory);
当我通过在文件对象中添加main-aot来更新我的tsconfig-aot
时,错误更改为"aot/src/app/app.module.ngfactory" has no exported member 'AppModuleNgFactory'
。我推测后者是因为尚未生成aot文件夹。请问我该如何正确配置?任何帮助将不胜感激。