html-withimg-loader icon indicating copy to clipboard operation
html-withimg-loader copied to clipboard

和html-webpack-plugin插件一起使用就会出现html parse失败

Open consunmida opened this issue 5 years ago • 5 comments

new webpackHtmlPlugin( { hash: true, minify: { collapseWhitespace: true, removeComments: true }, template: './index.html', filename: 'index.html' } ) 这样一起使用就会有问题

consunmida avatar Dec 02 '19 05:12 consunmida

me too have this problem, error message: ERROR in Error: Parse Error: <img src={"default":"c853dae0f18c964fe3f105cea94f9d34.jpg"} alt="12" />

  • htmlparser.js:240 new HTMLParser [webpack]/[html-minifier]/src/htmlparser.js:240:13

  • htmlminifier.js:966 minify [webpack]/[html-minifier]/src/htmlminifier.js:966:3

  • htmlminifier.js:1326 exports.minify [webpack]/[html-minifier]/src/htmlminifier.js:1326:16

  • index.js:316 Promise.resolve.then.then.html [webpack]/[html-webpack-plugin]/index.js:316:18

pszh avatar Dec 05 '19 02:12 pszh

请问怎么解决

holdbiao avatar Dec 12 '19 13:12 holdbiao

同样的问题,有人说在url-loader或者file-loader中加入esModule:false但是这个打包出的路劲是undefined

windeyes avatar May 01 '20 09:05 windeyes

同样的问题,有人说在url-loader或者file-loader中加入esModule:false但是这个打包出的路劲是undefined

如果是图片问题建议在url-loader里加入esModule:false,这样他的路径就不是对象之类了

Huang-junsen avatar Jun 17 '20 03:06 Huang-junsen

自定义了一个loader,return的时候加上defaut return str.replace(reg, attrName+"="+JSON.stringify(require("+JSON.stringify(imgUrl)+").default)+"");

EaVanCN avatar Sep 14 '21 09:09 EaVanCN