最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - extract-text-webpack-plugin replacement in webpack 5 - Stack Overflow

programmeradmin7浏览0评论

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 ponent), then bine all html files and output one single html. Here is the webpack config snippet:

.
.
.
# 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.

But in webpack 5, the extract-text-webpack-plugin is deprecated. The remanded replacement of this plugin is mini-css-extract-plugin, but it's specified for css, seems not work for other file types. By using asset module(asset/resource) from webpack 5, it will output multiple html files.

Currently I'm blocked by this, is there any replacement of extract-text-webpack-plugin can fulfill my requirement? or is there any other solutions for this?

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 ponent), then bine all html files and output one single html. Here is the webpack config snippet:

.
.
.
# 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.

But in webpack 5, the extract-text-webpack-plugin is deprecated. The remanded replacement of this plugin is mini-css-extract-plugin, but it's specified for css, seems not work for other file types. By using asset module(asset/resource) from webpack 5, it will output multiple html files.

Currently I'm blocked by this, is there any replacement of extract-text-webpack-plugin can fulfill my requirement? or is there any other solutions for this?

Share Improve this question asked Feb 21, 2022 at 12:52 OleyeyeOleyeye 811 silver badge3 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

See the repo which says it's replaced with mini-css-extract-plugin

发布评论

评论列表(0)

  1. 暂无评论