如何在Vuetify样式中使用手写笔块级导入

时间:2019-01-17 10:17:54

标签: less vuetify.js stylus

使用手写笔块级导入:

# vuetify-style.styl
.myapp
   @import '~vuetify/src/stylus/main'

这是为了确保vuetify css不会干扰页面其他部分未使用vuetify的元素。

但是不幸的是,它不起作用,我无法编译它。

ERROR  Failed to compile with 1 errors                                                                         2:13:28 pm

 error  in ./src/stylus/main.styl

Module build failed (from ./node_modules/stylus-loader/index.js):
Error: node_modules/vuetify/src/stylus/settings/_el
evations.styl:85:33
   81|                       0px 9px 46px 8px $shadow-key-ambient-opacity
   82| 
   83| // MIXINS
   84| elevation($z, important = false)
   85|   box-shadow: $shadow-key-umbra[$z],
---------------------------------------^
   86|               $shadow-key-penumbra[$z],
   87|               $shadow-key-ambient[$z] (important ? !important : )
   88| 

cannot perform $shadow-key-umbra[((0))]

仅当我删除第一行(.myapp)时才会编译

链接到github上的问题:https://github.com/vuetifyjs/vuetify/issues/4864

顺便说一句,我还尝试使用less并从包中导入CSS

# vuetify-style.less
vuetify-styles {
  @import (less) 'vuetify/dist/vuetify.css';
}

但是这样我也遇到了一个错误:

 ERROR  Failed to compile with 1 errors                                            11:57:30 AM

 error  in ./src/plugins/vuetify-styles.less

Module build failed:

// load the styles
var content = require("!!../../node_modules/css-loader/index.js??ref--9-1!../../node_modules/p
ostcss-loader/lib/index.js??ref--9-2!../../node_modules/less-loader/dist/cjs.js??ref--9-3!./vu
etify-styles.less");
          ^
Unrecognised input
      in /Users/zvadym/WorkProjects/motos_as/odin/vue/src/plugins/vuetify-styles.less (line 4,
 column 12)

 @ ./src/plugins/vuetify-styles.less 4:14-334 13:3-17:5 14:22-342
 @ ./src/plugins/vuetify.js
 @ ./src/crm/main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/crm/ma
in.js

1 个答案:

答案 0 :(得分:3)

找到了处理它的方法。实际上,我只是指定了样式文件的完整相对路径

.vuetify-styles {
  @import (less) '../../node_modules/vuetify/dist/vuetify.css';
}

并安装了less的{​​{1}}