一、安裝css-loader和style-loadercss
$ cnpm install css-loader style-loader --save-dev
二、引用的時候使用css-loader,讓webpack能夠打包css文件 webpack
require('css-loader!./style.css');
三、打包web
四、引入style-loader,將樣式經過style標籤寫到head標籤裏npm
require('style-loader!css-loader!./style.css');
一、引入css文件json
require('./style.css');
二、webpack命令指定css文件的處理方式函數
$ webpack hello.js hello.bundle.js --module-bind 'css=style-loader!css-loader'
文件改變的時候自動打包ui
$ webpack hello.js hello.bundle.js --module-bind 'css=style-loader!css-loader' --watch
查看打包進度spa
$ webpack hello.js hello.bundle.js --module-bind 'css=style-loader!css-loader' --progress
看見打包模塊3d
$ webpack hello.js hello.bundle.js --module-bind 'css=style-loader!css-loader' --progress --display-modules
打包緣由code
$ webpack hello.js hello.bundle.js --module-bind 'css=style-loader!css-loader' --progress --display-modules --display-reasons
"start":"webpack",//start是webpack系統函數名
執行:
$ cnpm start
或者不使用start,自定義如:
執行: