简体   繁体   English

webpack 5 中的 extract-text-webpack-plugin 替换

[英]extract-text-webpack-plugin replacement in webpack 5

I'm working on the project upgrading from webpack 3 to webpack 5. In the project, it was using raw-loader and extract-text-webpack-plugin to parse imported html file(angular component), then combine all html files and output one single html.我正在将项目从 webpack 3 升级到 webpack 5。在项目中,它使用 raw-loader 和 extract-text-webpack-plugin 来解析导入的 html 文件(角度组件),然后合并所有 html 文件并输出一个 html。 Here is the webpack config snippet:这是 webpack 配置片段:

.
.
.
# initialize the extractText plugin
const extractHTML = new ExtractTextPlugin({
    filename: `${assetsPattern}.[contenthash].html`,
    allChunks: true
.
.
.
# setup the loader
{
    test: /\.html$/,
    loader: extractHTML.extract('raw-loader')
}
.
.
.

As it's customized application, I require the html as a single file.由于它是定制的应用程序,我需要将 html 作为单个文件。

But in webpack 5, the extract-text-webpack-plugin is deprecated.但是在 webpack 5 中,extract-text-webpack-plugin 已被弃用。 The recommanded replacement of this plugin is mini-css-extract-plugin, but it's specified for css, seems not work for other file types.这个插件的推荐替换是 mini-css-extract-plugin,但它是为 css 指定的,似乎不适用于其他文件类型。 By using asset module(asset/resource) from webpack 5, it will output multiple html files.通过使用 webpack 5 中的资产模块(资产/资源),它将输出多个 html 文件。

Currently I'm blocked by this, is there any replacement of extract-text-webpack-plugin can fulfill my requirement?目前我被这个阻止了,是否有任何替代 extract-text-webpack-plugin 可以满足我的要求? or is there any other solutions for this?或者还有其他解决方案吗?

查看说它已替换为mini-css-extract-pluginrepo

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM