多入口文件编译
创建两个entry入口文件
$ cd src && mkdir entry1.js entry2.js
entry1.js
document.write('<h1>用友网络FED团队</h1>');
entry2.js
document.write('<h1>webpack完全教程</h1>');
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Webpack 完全教程</title>
</head>
<body>
<script src="./dist/entry1.js"></script>
<script src="./dist/entry2.js"></script>
</body>
</html>
webpack.config.js
const path = require('path');
module.exports = {
entry: {
bundle1: './src/entry1.js',
bundle2: './src/entry2.js'
},
output: {
path: './dist',
filename: '[name].js'
}
};
运行
$ npm run dev