使用带有.html条目的webpack

时间:2017-07-12 16:41:47

标签: webpack webpack-file-loader webpack-html-loader

如何从传统输入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

0 个答案:

没有答案