1

所以我最近ng update在我的 angular5 项目上运行了一个并将 angular cli 更新到版本 1.7.2 和 webpack 到 4.1.0。我可以使用没有错误地构建良好,ng build但是当我运行时ng build --prod出现以下错误:

78% advanced chunk optimizationD:\WORKSPACE\node_modules\webpack\lib\Chunk.js:465
                throw new Error("Chunk.entrypoints: Use Chunks.addGroup instead");
                ^

Error: Chunk.entrypoints: Use Chunks.addGroup instead
    at Chunk.set (D:\WORKSPACE\node_modules\webpack\lib\Chunk.js:465:9)
    at D:\WORKSPACE\node_modules\extract-text-webpack-plugin\dist\index.js:176:40
    at Array.forEach (<anonymous>)
    at Compilation.<anonymous> (D:\WORKSPACE\node_modules\extract-text-webpack-plugin\dist\index.js:171:18)
    at Compilation.applyPluginsAsyncSeries (D:\WORKSPACE\node_modules\tapable\lib\Tapable.js:206:13)
    at Compilation.seal (D:\WORKSPACE\node_modules\@angular\cli\node_modules\webpack\lib\Compilation.js:602:8)
    at applyPluginsParallel.err (D:\WORKSPACE\node_modules\@angular\cli\node_modules\webpack\lib\Compiler.js:504:17)
    at D:\WORKSPACE\node_modules\tapable\lib\Tapable.js:289:11
    at _addModuleChain (D:\WORKSPACE\node_modules\@angular\cli\node_modules\webpack\lib\Compilation.js:505:11)
    at processModuleDependencies.err (D:\WORKSPACE\node_modules\@angular\cli\node_modules\webpack\lib\Compilation.js:475:14)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)

不知道从这里做什么,有什么帮助吗?我可以发布我的webpack.config.jspackages.json如果有帮助的话。

4

1 回答 1

2

我使用 Angular CLI 1.7.2 将一个新项目引导到 GitHub 存储库中,并在每次提交中逐步更新它以使其使用 Webpack 4.0.1 构建。

https://github.com/fernandoespinosa/angular-cli-webpack4-sample/

要解决您当前的问题,您必须更新一些软件包:

npm i -D --save --force html-webpack-plugin@latest
npm i -D --save --force extract-text-webpack-plugin@4.0.0-beta.0

请记住,它CommonsChunkPlugin已被弃用,因此您必须将其从webpack.config.js中删除。您将不得不对ng eject这个文件进行一些操作。

ng eject --aot=true --target=production --build-optimizer=true
于 2018-03-05T15:35:21.260 回答