Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant