如何从传统输入webpack
开始,{@ 1}}将网络应用加入.html
文件?
这是一个简单的起点:
的index.html
.html
main.js
<body>
<output></output>
<script src="./main.js"></script>
</body>
webpack.config.js
import React from "react";
document.querySelector("output").innerText = React.version;
但是,处理module.exports = {
entry: "./index.html",
output: {
filename: "output.html"
},
module: {
rules: [
{test: /^index\.html$/, use: [
{loader: "extract-loader"},
{loader: "html-loader", options: {
attrs: ["script:src"]
}}
]}
]
}
}
时会产生SyntaxError: Unexpected token import
。