如何用webpack進行css的打包

來源:互聯網
上載者:User
我假設你環境已經安裝好了:

webpack預設是不支援打包css(style)的

需要安裝

npm install css-loader style-loader --save-dev

安裝完成之後,你還要在你引入css的地方前面加入 "css-loader!路徑"

// 打包之後css有效果需要加 style-loader 不然就沒有效果require('style-loader!css-loader!./style.css')


還有一種簡便的寫法

直接引入

require('./style.css')

在命令列

webpack hello.js hello.bundle.js --module-bind "css=style-loader!css-loader" --watch

只能你修改了 去頁面重新整理就可以使用了

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.