Answer the question
In order to leave comments, you need to log in
Webpack throws an error when processing an html file, how to fix it?
Greetings!
When building via Webpack, it gives errors. The essence of the error: when building home.html, webpack for some reason tries to find js code inside html tags.
Mistake:
ERROR in ./src/home.html (./node_modules/html-webpack-plugin/lib/loader.js!./src/home.html)
Module build failed (from ./node_modules/html-loader/index.js):
Error: Line 151: Unexpected identifier
at ErrorHandler.constructError (C:\1\node_modules\recast\node_modules\esprima\dist\esprima.js:3396:22)
at ErrorHandler.createError (C:\1\node_modules\recast\node_modules\esprima\dist\esprima.js:3414:27)
at JSXParser.Parser.unexpectedTokenError (C:\1\node_modules\recast\node_modules\esprima\dist\esprima.js:542:39)
at JSXParser.Parser.throwUnexpectedToken (C:\1\node_modules\recast\node_modules\esprima\dist\esprima.js:552:21)
at JSXParser.Parser.consumeSemicolon (C:\1\node_modules\recast\node_modules\esprima\dist\esprima.js:845:23)
at JSXParser.Parser.parseExpressionStatement (C:\1\node_modules\recast\node_modules\esprima\dist\esprima.js:2080:15)
at JSXParser.Parser.parseStatement (C:\1\node_modules\recast\node_modules\esprima\dist\esprima.js:2495:35)
at JSXParser.Parser.parseStatementListItem (C:\1\node_modules\recast\node_modules\esprima\dist\esprima.js:1823:31)
at JSXParser.Parser.parseProgram (C:\1\node_modules\recast\node_modules\esprima\dist\esprima.js:3061:29)
at Object.parse (C:\1\node_modules\recast\node_modules\esprima\dist\esprima.js:117:24)
<code class="jscript plain">logs.error(`Info of error`, { moduleName:
<code class="jscript plain">node.classList.add(...node.getAttribute(`data-${
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
},
},
{
test: /\.html$/,
exclude: /node_modules/,
use: {
loader: "html-loader",
options: {
attrs: [
"img:src",
"link:href",
":data-src",
],
interpolate: true,
},
},
},
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question