I'm getting the following error when trying to build an HTML page with webpack (no SPA frameworks/libs involved)
- htmlparser.js:244 new HTMLParser
[htmlapp-webpack]/[html-webpack-plugin]/[html-minifier]/src/htmlparser.js:244:13
- htmlminifier.js:980 minify
[htmlapp-webpack]/[html-webpack-plugin]/[html-minifier]/src/htmlminifier.js:980:3
- htmlminifier.js:1341 Object.exports.minify
[htmlapp-webpack]/[html-webpack-plugin]/[html-minifier]/src/htmlminifier.js:1341:16
- index.js:441 HtmlWebpackPlugin.postProcessHtml
[htmlapp-webpack]/[html-webpack-plugin]/index.js:441:34
- index.js:274 Promise.all.then.then
[htmlapp-webpack]/[html-webpack-plugin]/index.js:274:25
When running in dev everything works smootly. This happens only when trying to build, this is how I configured the dev and build tasks in package.json:
"scripts": {
"build": "webpack -p --progress --mode production --config webpack.config.js",
"start": "npm run dev"
"dev": "cross-env NODE_ENV=dev webpack-dev-server --open --config webpack.config.js",
}
The errors appear to happen when webpack tries to bundle the images, because I see lot of base64 transformations in the error message
And here is my webpack configuration for images loader:
{
test: /\.(gif|png|jpe?g|svg)$/i,
use: [
{
loader: "url-loader",
options: {
limit: 8192,
name: "[path][name].[ext]?[hash]",
fallback: "file-loader"
}
},
{
loader: "image-webpack-loader",
options: {
mozjpeg: {
progressive: true,
quality: 65
},
pngquant: {
quality: "65-90",
speed: 4
},
gifsicle: {
interlaced: false
},
svgo: {
plugins: [
{ removeTitle: true },
{ convertColors: { shorthex: false } },
{ convertPathData: false }
]
},
webp: {
quality: 75
}
}
}
]
}
Hope you guys can help me to solve this, I've been searching for a solution for the last two days and still with no success.
UPDATE
This is how the HTML code is written, nothing fancy here
<div class="wrapper">
<div data-aos="fade-up">
<img src="./public/img/some-shape.svg" class="img" alt="">
</div>
...
</div>
