一、安装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,自定义如:
执行: