Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
consunmida opened this issue Dec 2, 2019 · 5 comments
Open

Comments

@consunmida
Copy link

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

@pszh
Copy link

pszh commented Dec 5, 2019

me too have this problem, error message:
ERROR in Error: Parse Error: <img src={"default":"c853dae0f18c964fe3f105cea94f9d34.jpg"} alt="12" /> <script type="text/javascript" src="output9f9f7f44.js"></scrip t>

  • 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

@holdbiao
Copy link

请问怎么解决

@windeyes
Copy link

windeyes commented May 1, 2020

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

@Huang-junsen
Copy link

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

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

@EaVanCN
Copy link

EaVanCN commented Sep 14, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants