webpack打包css

來源:互聯網
上載者:User

標籤:code   bin   其他   安裝   改變   ons   ack   參數說明   --   

1、第一種方式

1、安裝css-loader和style-loader

$ cnpm install css-loader style-loader --save-dev

2、引用的時候使用css-loader,讓webpack可以打包css檔案 

require(‘css-loader!./style.css‘);

3、打包

4、引入style-loader,將樣式通過style標籤寫到head標籤裡

require(‘style-loader!css-loader!./style.css‘);
 2、第二種方式

1、引入css檔案

require(‘./style.css‘);

2、webpack命令指定css檔案的處理方式

$ webpack hello.js hello.bundle.js --module-bind ‘css=style-loader!css-loader‘

3、第三種方式

檔案改變的時候自動打包

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

4、其他webpack打包時的參數說明

查看打包進度

$ webpack hello.js hello.bundle.js --module-bind ‘css=style-loader!css-loader‘ --progress

看見打包模組

$ webpack hello.js hello.bundle.js --module-bind ‘css=style-loader!css-loader‘ --progress --display-modules 

打包原因

$ webpack hello.js hello.bundle.js --module-bind ‘css=style-loader!css-loader‘ --progress --display-modules --display-reasons

 

webpack打包css

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.