【发布时间】:2018-07-21 06:39:00
【问题描述】:
我已根据tutorial 将 Angular 4 更新为 5,此后我在 webpack 上的构建失败并出现两个警告:
WARNING in ./node_modules/@angular/core/esm5/core.js
6553:15-36 Critical dependency: the request of a dependency is an expression
@ ./node_modules/@angular/core/esm5/core.js
@ ./ClientApp/boot.browser.ts
@ multi event-source-polyfill webpack-hot-middleware/client?path=__webpack_hmr&dynamicPublicPath=true ./ClientApp/boot.browser.ts
WARNING in ./node_modules/@angular/core/esm5/core.js
6573:15-102 Critical dependency: the request of a dependency is an expression
@ ./node_modules/@angular/core/esm5/core.js
@ ./ClientApp/boot.browser.ts
@ multi event-source-polyfill webpack-hot-middleware/client?path=__webpack_hmr&dynamicPublicPath=true ./ClientApp/boot.browser.ts
我经历了这个topic,但没有任何帮助(也许我错过了什么)。这就是我的 webpack.config.vendor.js 插件的外观:
plugins: [
new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery', Popper: 'popper.js' }), // Maps these identifiers to the jQuery package (because Bootstrap expects it to be a global variable)
new webpack.ContextReplacementPlugin(/\@angular\b.*\b(bundles|linker)/, path.join(__dirname, './ClientApp')), // Workaround for https://github.com/angular/angular/issues/11580
new webpack.ContextReplacementPlugin(/angular(\\|\/)core(\\|\/)@angular/, path.join(__dirname, './ClientApp')), // Workaround for https://github.com/angular/angular/issues/14898
new webpack.IgnorePlugin(/^vertx$/) // Workaround for https://github.com/stefanpenner/es6-promise/issues/100
]
我最初使用来自 Visual Studio 的 .NET Core API 的 Angular 模板。
【问题讨论】:
-
您是否运行
webpack --config webpack.config.vendor.js以查看是否清除了警告?过去,当使用您使用的模板从 ng4 迁移到 ng5 时,这对我有用。 -
你说得对!您可以发表评论作为答案吗?所以我可以接受你的回答。谢谢。
-
完成!很高兴这有帮助。
-
是的,这是一个棘手的问题。这通常发生在第一次构建时,但如果供应商文件已经存在 VS2017 模板不会重新创建它(检查您的 *.csproj 文件,构建命令在那里)。还删除 dist 文件夹(在 wwwroot 和项目文件夹中也有帮助,因为它会在您构建 asp.net 核心项目时触发它再次构建
标签: angular webpack asp.net-core