Reactjs bundle.js包含在webpack生成的index.html中两次
我的webpack 4在build文件夹中生成index.html,bundle.js在生成的index.html中包含两次 文件夹结构Reactjs bundle.js包含在webpack生成的index.html中两次,reactjs,webpack,webpack-4,Reactjs,Webpack,Webpack 4,我的webpack 4在build文件夹中生成index.html,bundle.js在生成的index.html中包含两次 文件夹结构 ui > webpack.config.js index.html build > index.html bundle.js ui-->index.html <html> <head> <link href="https://fonts.googlea
ui >
webpack.config.js
index.html
build >
index.html
bundle.js
ui-->index.html
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Cabin+Sketch" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<div id="App">
<!-- this is where the root react component will get rendered -->
</div>
<script type="text/javascript" src="/bundle.js"></script></body>
</html>
生成文件夹下的webpack generated index.html
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Cabin+Sketch" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<div id="App">
<!-- this is where the root react component will get rendered -->
</div>
<script src=build/rapido-web.js></script>
<script type="text/javascript" src="/rapido-web.js"></script>
</body>
</html>
知道bundle.js为什么包含两次吗?从index.html中删除对
bunde.js
的手动引用HtmlWebpackPlugin
将bundle注入到html开箱即用从index.html中删除对bunde.js的手动引用。HtmlWebpackPlugin将捆绑注入到thml中。感谢您的回答。如果你觉得我的问题是正确的,请投票表决。