vite-plugin-css

提供组件库的样式按需加载

Usage no npm install needed!

<script type="module">
  import vitePluginCss from 'https://cdn.skypack.dev/vite-plugin-css';
</script>

README

vite-css-plugin

Install

npm install -D vite-css-plugin
# or
yarn add -D vite-css-plugin

Usage

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import css from 'vite-css-plugin';
export default defineConfig({
  plugins: [vue(), css({
    name: 'ant-design-vue',
    tranfrom(component) {
      let name = component;
      if (/Row|Col/.test(component)) name = 'grid';
      return `lib/${name.toLowerCase()}/style/index.css`;
    }
  })]
})

input

import { Button } from 'ant-design-vue';

output

import 'ant-design-vue/lib/button/style/index.css';
import { Button } from 'ant-design-vue';