use the plugin with vite-plugin-import-style, but style not loaded
See original GitHub issueconfig as follows:
// main.ts
import { createApp } from 'vue'
// import { Button } from 'ant-design-vue'
// import Antd from 'ant-design-vue'
import App from './App.vue'
import 'virtual:windi.css'
const app = createApp(App);
// app.use(Button)
// app.use(Antd)
app.mount('#root', true)
// vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ViteComponents, {
AntDesignVueResolver
} from 'vite-plugin-components'
// import ViteCompression from 'vite-plugin-compression'
import ViteStyleImport from 'vite-plugin-style-import'
import WindiCSS from 'vite-plugin-windicss'
// https://vitejs.dev/config/
export default defineConfig({
// 1. If you are using the ant-design series, you need to configure this
// 2. Make sure less is installed in the dependency `yarn add less -D`
css: {
preprocessorOptions: {
less: {
// modifyVars: {},
javascriptEnabled: true,
},
},
},
plugins: [
vue(),
// https://github.com/antfu/vite-plugin-components
ViteComponents({
globalComponentsDeclaration: true,
customComponentResolvers: [
AntDesignVueResolver(),
]
}),
// https://github.com/windicss/vite-plugin-windicss
WindiCSS(),
// https://github.com/anncwb/vite-plugin-compression
// ViteCompression(),
// https://github.com/anncwb/vite-plugin-style-import
ViteStyleImport({
libs: [
{
libraryName: 'ant-design-vue',
esModule: true,
resolveStyle: (name) => {
return `ant-design-vue/es/${name}/style/index`;
},
}
]
}),
]
})
<template>
<a-button type="primary">Ant Button</a-button>
</template>
style not generate
what should i do
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
vbenjs/vite-plugin-style-import - GitHub
Why only import styles. Because vite itself has imported the component library on demand, only the style is not on demand, so just...
Read more >Features | Vite
In this case, the processed CSS string is returned as the module's default export as usual, but the styles aren't injected to the...
Read more >vite-plugin-federation doesn't load the styles of my components
This is my vite.conf.ts: import federation from "@originjs/vite-plugin-federation"; import { ...
Read more >Vite error ( not showing CSS styles) - Laracasts
I have hosted an app to a Server, and everything is fine except that the Vite file causes two errors on my Browser....
Read more >vite-plugin-style-import - npm
Start using vite-plugin-style-import in your project by running `npm i ... the style is not on demand, so just import the style on...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You can use
customComponentResolvers
withsideEffects
option to import the style (no need to use ViteStyleImport).Here is my config:
The full example of this can be found here https://github.com/ngekoding/vite-project-explore
@agoni1212 Ah you are right, after trying that component I got errors. Actually currently I use ElementUI library, so don’t know that problem before, maybe I need make a test for adv next time.