来自 VS 2017 的 .net Core Webpack 发布失败 [英] .net Core Webpack Publish from VS 2017 failing
问题描述
我正在尝试将 .net Core Angular 4 项目从 Visual Studio 发布到 Azure.在发布期间,我收到以下错误:
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:projectsDataFinchPinnacleDataFinch.Pinnacle.Web$$_gendir
ode_modulesangular-tree-componentdistcomponents ree.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' },
你可以看看 my webpack.config.js 这是默认的 asp.net core spa angular 4 模板为 angular 5 更新(直到支持 angular 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屋!