Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs bundle.js包含在webpack生成的index.html中两次_Reactjs_Webpack_Webpack 4 - Fatal编程技术网

Reactjs bundle.js包含在webpack生成的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

我的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.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中。感谢您的回答。如果你觉得我的问题是正确的,请投票表决。