首先npm install webpack -g
npm install live-server -g
开始新建一个文件夹demo1,在demo1里创建index.html和webpack.config.js以及main.js
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
</body>
<script type="text/javascript" src="./main.js"></script>
</html>
main.js
document.write("<h1>Hello world !</h1>")
webpack.config.js
module.exports={
entry:'./main.js';
output:{
filename:"bundle.js"
}
}
//控制台输入webpack,bundle.js会被加载到页面文件夹中
网友评论