webpack window 使用sass來編譯css樣式

來源:互聯網
上載者:User

標籤:

1.執行安裝:

npm install sass-loader --save-dev (此處不行的話就換上npm install node-sass)

2.稍微修改一下config,刪掉我們先前添加的css規則,加上下面的loader


      {        test: /\.scss$/,        loaders: [‘style‘, ‘css‘, ‘sass‘],        include: APP_PATH      },

添加兩個sass檔案,variables.scss和main.scss

variables.scss


$red: red;

main.scss


@import "./variables.scss";h1 {  color: $red;}

在index.js中引用


require(‘./main.scss‘);

然後發現標題如願變紅,相當簡單吧。

來源:連結:http://zhuanlan.zhihu.com/p/20367175

webpack window 使用sass來編譯css樣式

相關文章

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.