webpack 的简单实用
2017-11-06 本文已影响0人
sunflower_07
- 首先需要安装node ,不确定自己有没有安装node,使用命令
node -v

- 初始化下,点回车就好了


3.安装webpack

4.新建个entry.js文件
写入document.write("It works.");
5.新建个index.html文件
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script type="text/javascript" src="bundle.js" charset="utf-8"></script>
</body>
</html>
6.在运行如下命令
$ webpack ./entry.js bundle.js

7.这时候你的demo 里面会有bundle.js 这个文件,这个就是打包之后的文件

8.这时候去打开index.html ,浏览器就会出现你写入的内容

一个简单的使用就完成了,你想了解更多,请去看api 吧。