新建文件夾,按住shift右擊選擇在此處打開命令窗口。
npm init
npm install webpack --save-dev
新建hello.js文件,function hello(str){ alert(str); }
webpack hello.js hello.bundle.js
新建world.js文件 function world(){ return { } }
改hello.js爲 require("./world.js");
運行
新建style.css body{background:#ccc;}
改hello.js爲require("style-loader!css-loader!./style.css");
npm install css-loader style-loader --save-dev
新建index.js文件<script src="hello.bundle.js"></script> hello.js文件加上hello('hello world!');
webpack用法1
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.