我的webpack 4在build文件夹中生成index.html,并且bundle.js在生成的index.html中包含两次。
文件夹结构
ui >
webpack.config.js
index.html
build >
index.html
bundle.js
用户界面-> 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在构建文件夹下生成了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都会包含两次
答案 0 :(得分:1)
从index.html中删除对bunde.js
的手动引用。 HtmlWebpackPlugin
开箱即用地将捆绑软件注入html