如何使用带有 Vuetify 样式的触控笔块级导入

How to use stylus block level import with Vuetify styles

使用手写笔块级导入:

# 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)

Link 到 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

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

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

并安装了 less 当然 npm install -D less less-loader