VS 2017的.net Core Webpack发布失败 [英] .net Core Webpack Publish from VS 2017 failing
问题描述
我正在尝试从Visual Studio向Azure发布.net Core Angular 4项目。在发布过程中,出现以下错误:
I am trying to publish a .net Core Angular 4 project from Visual Studio to Azure. During the publish, I get the following error:
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时,我似乎无法发布:
Everything works fine on my local machine, I just cant seem to publish when env is set to prod:
更新:
此处是我的 Webpack.js 文件。
推荐答案
确保您的webpack文件包含适当的模块规则:
Make sure that your webpack file contains an appropriate module rule:
{ test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/, include: [/ClientApp/, /\$\$_gendir/], use: isDevBuild ? ['awesome-typescript-loader?silent=true', 'angular2-template-loader'] : '@ngtools/webpack' },
您可以查看我的webpack.config.js 这是默认的asp.net核心spa角度4模板,已针对角度5更新(直到发布了支持角度CLI的spa服务版本)
You can have a look at my webpack.config.js which is the default asp.net core spa angular 4 template updated for angular 5 (until the version of the spa services supporting the angular CLI is released)
这篇关于VS 2017的.net Core Webpack发布失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!