Entrypoint undefined = index.html html-webpack-plugin 错误ERROR in Error: Child compilation failed: Module build failed (from ./node_modules/html-webpack-plu SyntaxError: Unexpected token )

Entrypoint undefined = index.html html-webpack-plugin 错误

ERROR in Error: Child compilation failed:
Module build failed (from ./node_modules/html-webpack-plu
SyntaxError: Unexpected token )

Child html-webpack-plugin for "index.html":
1 asset
Entrypoint undefined = index.html
[0] ./node_modules/html-webpack-plugin/lib/loader.js!./
[built] [failed] [1 error]

错误步骤重现

话说使用 html-withimg-loader 处理图片之后, html 中就不能使用 vm, ejs 的模板了,如果想继续在 html 中使用 <% if(htmlWebpackPlugin.options.config.header) { %> 这样的语法,但是呢,又希望能使用本地图片,可不可以?鱼和熊掌都想要,虽然很多时候,能吃个鱼就不错了,但是这里是可以的哦,像下面这样编写图片的地址,并且删除 html-withimg-loader的配置即可。

出现这个问题的原因是我使用了  html-withimg-loader   然后配置后,但是打包后出现了问题,打包后的html成了这个鬼样子,

注释配置卸掉这个node_modules后,报错

但是问题尝试了很多种,无法解决,我没办法又给它装上了,

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <% if(htmlWebpackPlugin.options.config.header) { %>
    <link rel="stylesheet" type="text/css" href="//common/css/header.css">
    <% } %>
    <title><%= (htmlWebpackPlugin.options.config.title) %></title>
</head>

<body>
  <div>20200303</div>
  <!-- <img src="./img/a.jpeg" /> -->
  <img src="<%= require('./img/a.jpeg') %>" />
</body> 
<% if(htmlWebpackPlugin.options.config.header) { %>
<script src="//common/header.min.js" type="text/javascript"></script> 
<% } %>
</html>

很抱歉 ,

我没解决问题,

请已经解决问题的小伙伴,

可以回复我一下哦~~~~

猜你喜欢

转载自www.cnblogs.com/sugartang/p/12407765.html