1.創建項目,項目名app
mkdir app
2.進入app的目錄
cd app
3.在項目的根目錄下創建runoob1.js文件
echo document.write("It works"); > runoob1.js
4.查看該目錄下生成的文件
dir
5.查看runoob1.js文件中的內容
type runoob1.js
6.在項目的根目錄下創建index.html文件
echo ... > index.html
7.修改index.html文件的內容,內容如下
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<link rel="stylesheet" href="">
</head>
<body>
<script type="text/javascript" src="bundle.js" charset="utf-8"></script>
</body>
</html>
8.查看已修改後的index.html文件的內容
type index.html
9.安裝webpack
cnpm install webpack
10.打包runoob1.js文件爲bundle.js
webpack runoob1.js bundle.js
11.在瀏覽器中打開index.html文件,輸出內容如下