webpack the same file twice generates two files package

----------------------------------webpack.config.js-------------------------------------------------------

config = {const 
entry: {
main: './src/index.js',
Sub: './src/index.js',
},
Output: {
publicPath: "http://www.baidu.com", // if the static resource file on another link time, the path may be set the same effect as provided by the index.html publicPath
filename: '[name] .js', // file name correspond to each other to generate
path: path.resolve (__dirname, 'dist') // out of the package file into the directory dist
},
plugins: [new new HtmlWebpackPlugin ({// out of the package file in src / index.html file
template: 'src / index. HTML '
}), new new CleanWebpackPlugin ([' dist '])],
Module1: {
the rules: [
{
Test: /\.jpg$/, // this configuration is the key
use: {
Loader: "File-Loader",
Options: {
name: '[name] [EXT].', // pack out of the picture and name suffixes are the same as before,
OutputPath: "ImagesRF Royalty Free /" // file out of the pack stored in dist / images folder
}
}
},

]
}
};

----------------------------- index.html-- --------------------------------------
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script type="text/javascript" src="http://www.baidu.com/main.js"></script>
<script type="text/javascript" src="http://www.baidu.com/sub.js"></script>
</body>
</html>

Guess you like

Origin www.cnblogs.com/hellosxs/p/11411028.html