How can I webpackweb application into output file .htmlstarting with traditional input .html?
Here is a simple starting point:
index.html
<body>
<output></output>
<script src="./main.js"></script>
</body>
main.js
import React from "react"
document.querySelector("output").innerText = React.version
webpack.config.js
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"]
}}
]}
]
}
}
This results SyntaxError: Unexpected token importin processing main.js.
source
share