0

使用 VueRouter 之后, Vite 里面的 css preprocessorOptions 失效了,可能是什么原因...

 2 years ago
source link: https://www.v2ex.com/t/831114
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  程序员

使用 VueRouter 之后, Vite 里面的 css preprocessorOptions 失效了,可能是什么原因?

  movq · 1 天前 · 514 次点击

使用 Vite+Vue3+VueRouter+TypeScript 开发

一开始的时候我没有引入 VueRouter

这时候我在 vite.config.ts 里面进行了 css 配置,重写了我 UI 框架的一些变量

这些重写都是有效的

  css: {
    preprocessorOptions: {
      less: {
        modifyVars: {
          'primary-color': '#1DA57A',
          'layout-header-background': '#FFFFFF',
          "tag-font-size": '8px',
        }
        ,
        javascriptEnabled: true
      }
    }
  },

但是引入 VueRouter 之后,这些配置就没用了,可能是什么原因?

第 1 条附言  ·  1 天前

我试了一下,如果我在单个 vue 组件里面,把<style></style>标签改成<style lang="less"></style>
然后里面写:

<style lang="less">
@import 'ant-design-vue/dist/antd.less';
</style>

那么在这单个组件内,就可以生效

问题是 vue router 到底破坏了什么,才导致现在这种状况?

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK