15

我正在处理一个反应项目,当我将 webpack 4.44.2 更新到 5.4.0 时,我收到以下消息:

[DEP_WEBPACK_COMPILATION_ASSETS] DeprecationWarning: Compilation.assets will be frozen in future, all modifications are deprecated.
BREAKING CHANGE: No more changes should happen to Compilation.assets after sealing the Compilation.
    Do changes to assets earlier, e. g. in Compilation.hooks.processAssets.
    Make sure to select an appropriate stage from Compilation.PROCESS_ASSETS_STAGE_*.
(Use `node --trace-deprecation ...` to show where the warning was created)

我搜索了很多,但没有得到确切的答案。那么我该如何解决呢?

4

3 回答 3

22

2021 年更新,2 月 25 日

Html-webpack-plugin v5 发布,运行即可

npm i -D html-webpack-plugin@latest

或者

npm uninstall html-webpack-plugin

npm i -D html-webpack-plugin

原始答案

这主要与 html-webpack-plugin 相关,虽然它的新版本 5(与 webpack v5 集成)仍处于测试阶段,但您应该手动更新它:

npm show html-webpack-plugin version 
4.5.1

npm show html-webpack-plugin@next version
5.0.0-beta.5

npm i -D html-webpack-plugin@next
于 2021-01-16T15:05:29.470 回答
5

你在运行命令npx webpack吗?如果是这样,您可以使用:

$ node --trace-deprecation ./node_modules/.bin/webpack

它应该向你展示所有产生这些警告的 webpack 插件。

于 2020-11-13T12:13:05.400 回答
2

这些贬损警告可以忽略不计。根本案例是违反全新 Webpack 5 规范的插件。总有一天他们会一起荡秋千(一段时间)。

您可以[DEP_WEBPACK_COMPILATION_ASSETS]通过更新 npm 包来解决问题。检查最新版本:

npm outdated

这对我有用,但现在我得到了[DEP_WEBPACK_COMPILATION_OPTIMIZE_CHUNK_ASSETS]. 等着瞧吧。

于 2021-02-08T15:32:31.183 回答