我的webpack入口点包括一个[hash]的名字:
- entry: "index.js",output: {
- path: "build/",filename: "index-[hash].js",}
如何从应用程序的HTML直接链接到该入口点?
例如,我希望发送给客户端的HTML包含:
- <script src="build/index-41d40fe7b20ba1dce81f.js"></script>
解决方法
html-webpack-plugin(我是作者)将为您引用一个引用正确的散列包文件名的index.html.
- var HtmlWebpackPlugin = require("html-webpack-plugin");
- var webpackConfig = {
- entry: "index.js",output: {
- path: "build/",},plugins: [new HtmlWebpackPlugin()]
- }
这将产生build / index.html,其中包含< script>标签.