小编ari*_*stf的帖子

Html-Webpack-Plugin 模板:模块构建失败:SyntaxError:意外的标记

当我尝试使用 index.ejs 模板文件使用 html-webpack-plugin 进行构建时,会引发以下错误:

即使我尝试加载为 .html 文件或安装 ejs-loader,仍然失败。我不确定 ejs-loader 是否与 html-webpack-plugin 一起安装。

其他一些人也有同样的问题,但是他们的 webpack 版本是 @1 并且该链接上的解决方案对我不起作用。,

https://github.com/jantimon/html-webpack-plugin/issues/273

./node_modules/html-webpack-plugin/lib/loader.js!./src/index.ejs 中出现错误

模块构建失败:语法错误:意外的标记 (1:1)

错误图像

src/index.ejs

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/assets/css/bootstrap.min.css">
    <title>My Library</title>
  </head>
  <body>
    <div class="main-content"></div>
    <footer class="footer-container"><p><span>Source: </span><a href="https://github.com/arikanmstf/mylibrary">https://github.com/arikanmstf/mylibrary</a></p></footer>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

webpack.config.js:

const ExtractTextPlugin = require("extract-text-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const UglifyJSPlugin = require("uglifyjs-webpack-plugin");
const webpack = require("webpack");
const argv = require("yargs").argv;
const path = require("path");

const extractCSS = new ExtractTextPlugin("dist/style.css");

const …
Run Code Online (Sandbox Code Playgroud)

webpack html-webpack-plugin

5
推荐指数
1
解决办法
8036
查看次数

标签 统计

html-webpack-plugin ×1

webpack ×1