1、在本建立vue项目的文件下打开命令窗口

2、输入: cnpm install sass-loader node-sass vue-style-loader --D 下载

3、打开项目文件下的build文件,找到webpack-base-conf.js文件,配置以下内容即可

module: {
    rules: [
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: vueLoaderConfig
      },
      {
        test: /\.js$/,
        loader: 'babel-loader',
        include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]
      },
      {
        test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
        loader: 'url-loader',
        options: {
          limit: 10000,
          name: utils.assetsPath('img/[name].[hash:7].[ext]')
        }
      },
      {
        test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
        loader: 'url-loader',
        options: {
          limit: 10000,
          name: utils.assetsPath('media/[name].[hash:7].[ext]')
        }
      },
      {
        test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
        loader: 'url-loader',
        options: {
          limit: 10000,
          name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
        }
      },
      {
      	//SCSS加载  识别sass-loader编译的部分 
      	test:/\.scss$/,
      	loaders:["style","css","sass"]
      }

主要是添加: 

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

4、使用方式

在相关文件中这样写即可使用scss来写css

<style rel="stylesheet/scss" lang="scss" scoped></style>

Logo

前往低代码交流专区

更多推荐