我正在尝试将.net Core Angular 4项目从Visual Studio发布到Azure。在发布期间,我收到以下错误:
ERROR in ./$$_gendir/~/angular-tree-component/dist/components/tree.component.ngfactory.ts
Module parse failed: C:\projects\DataFinch\Pinnacle\DataFinch.Pinnacle.Web\$$_gendir\node_modules\angular-tree-component\dist\components\tree.component.ngfactory.ts Unexpected token (21:26)
You may need an appropriate loader to handle this file type.
| import * as i10 from 'angular-tree-component/dist/components/tree.component';
| import * as i11 from 'angular-tree-component/dist/models/tree-dragged-element.model';
| const styles_TreeComponent:any[] = ([] as any[]);
| export const RenderType_TreeComponent:i0.RendererType2 = i0.╔╡crt({encapsulation:2,
| styles:styles_TreeComponent,data:{}});
@ ./$$_gendir/ClientApp/app/components/settings/positions/positionsList.component.ngfactory.ts 11:0-127
@ ./$$_gendir/ClientApp/app/app.module.browser.ngfactory.ts
@ ./ClientApp/boot.browser.ts
在我的本地机器上一切正常,当env设置为prod时,我似乎无法发布:
更新 这是我的Webpack.js文件。
答案 0 :(得分:2)
确保您的webpack文件包含适当的模块规则:
{ test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/, include: [/ClientApp/, /\$\$_gendir/], use: isDevBuild ? ['awesome-typescript-loader?silent=true', 'angular2-template-loader'] : '@ngtools/webpack' },
您可以查看my webpack.config.js这是为角度5更新的默认asp.net核心spa角度4模板(直到支持角度CLI的spa服务版本发布)