Home  >  Article  >  Web Front-end  >  Vue globally introduces bass.scss implementation steps

Vue globally introduces bass.scss implementation steps

php中世界最好的语言
php中世界最好的语言Original
2018-05-03 11:06:272208browse

This time I will bring you the steps to implement Vue's global introduction of bass.scss. What are the precautions for Vue's global introduction of bass.scss. The following is a practical case, let's take a look.

Installation

$ > cnpm i -D sass-resources-loader

Configuration

If configured, it is configured in the loader parser of vue, that is, in vue-cli The file built in the scaffolding mode is build/utils.js, and the cssLoaders() method is defined in this file. This method defines the parsing methods of css and less, as follows.

// build/utils.js
exports.cssLoaders = function (options) {
 options = options || {}
 ...
 return {
  // ...
  sass: generateLoaders('sass', { indentedSyntax: true }),
  // 定义在这里 =======================》
  scss: generateLoaders('sass').concat(
   {
    loader: 'sass-resources-loader',
    options: {
     resources: path.resolve(dirname, '../src/common/style/global.scss') // 需要全局引入的文件
    }
   }
  ),
  // 定义在这里 =======================》
  // ...
 }
}
// global.scss
@mixin line-height($height) {
 height: $height;
 line-height: $height;
}
$head-height: .45rem;
// xx.vue
<style lang="scss">
 height: @include line-height(45px);
</style>

Recommendation

Only need to define variables or mixins in global.scss.

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

WeChat applet shares the page and jumps back to the homepage

ElTableColumn adds search summary function

Detailed explanation of using Vue watch

The above is the detailed content of Vue globally introduces bass.scss implementation steps. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn