0
如何使用webpack从几个脚本制作一个包?我试图指出几个条目,但只包括最后,其他只是没有看到如何功能。如何使用webpack从几个脚本制作一个包?
这是我的APP1:
function setCats() {
alert('cat');
}
exports.setCats = setCats;
我APP 2:
function setDogs() {
alert('dog');
}
exports.setDogs = setDogs;
我的index.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="bin/app.bundle.js" charset="utf-8"></script>
</head>
<body>
<script>app.setCats()</script>
<script>app.setDogs()</script>
</body>
</html>
我webpack.config.js:
module.exports = {
entry: {
app: [
'./src/app1.js',
'./src/app2.js',
]
},
output: {
path: './bin',
filename: 'app.bundle.js',
library: 'app'
},
module: {
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
}]
},
};
建设和浏览器中运行后,惊动了刚刚狗和控制台我有这样的错误:
index.html:8 Uncaught TypeError: app.setCats is not a function
谢谢:)
非常感谢) –