vue-cli sass安裝


一、安裝對應依賴node模塊:

npm install node-sass --save-dev
npm install sass-loader --save-dev

二、打開webpack.base.config.js在loaders里面加上

rules: [
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: vueLoaderConfig
      },
      {
        test: /\.js$/,
        loader: 'babel-loader',
        include: [resolve('src'), resolve('test')]
      },
      {
        test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
        loader: 'url-loader',
        query: {
          limit: 10000,
          name: utils.assetsPath('img/[name].[hash:7].[ext]')
        }
      },
      { test: /\.scss$/,
        loaders: ["style", "css", "sass"] },
      {
        test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
        loader: 'url-loader',
        query: {
          limit: 10000,
          name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
        }
      }
    ]
  }

三、在.vue文件中

<style lang="scss" type="text/css">
    @import url('common/css/reset.css');

    $vw_base: 375; 
    @function vw($px) {
        @return ($px / 375) * 100vw;
    }

    .main {
        display: flex;
        width: vw(50);
    }
</style>

 原文: https://www.cnblogs.com/rainheader/p/6505366.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM