Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

antdv: warning: "@charset" must be the first rule in the file #55

Closed
wubiandaxian opened this issue Dec 2, 2021 · 3 comments
Closed

Comments

@wubiandaxian
Copy link
Contributor

环境:
vite: 2.6.11
vite-plugin-style-import: 1.4.0
ant-design-vue: 3.0.0-alpha.12

vite按需加载配置:

styleImport({
        libs: [
          {
            libraryName: 'ant-design-vue',
            esModule: true,
            resolveComponent: (name) => `ant-design-vue/es/${name}`,
            resolveStyle: (name) => `ant-design-vue/es/${name}/style/index`,
          },
        ],
      }),

vite中css预处理的配置

css: {
      preprocessorOptions: {
        less: {
          charset: false,
        },
        scss: {
          charset: false,
        },
        css: {
          charset: false,
        },
      },
    },

问题:
如果打包的时候,加入了按需引入,就会报如下warning

:4004:0: warning: "@charset" must be the first rule in the file
4004 │ @charset "UTF-8";
╵ ~~~~~~~~
:3972:0: note: This rule cannot come before a "@charset" rule
3972 │ .ant-spin.ant-spin-show-text .ant-spin-text {
╵ ^

不添加按需引入的配置打包是没有问题的。目前不知道问题出在哪,就来这提issues了

@wubiandaxian
Copy link
Contributor Author

如果按需加载的配置中不写 resolveStyle,也不会报warning

@wubiandaxian
Copy link
Contributor Author

vite的issues里找到了解决办法,但是我依旧不知道这是属于谁的bug

vite: build includes @charset problem.#5833

@wubiandaxian
Copy link
Contributor Author

wubiandaxian commented Dec 21, 2021

esbuild的问题: evanw/esbuild#1862

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant