Skip to content

wxsms/vite-plugin-libcss

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vite-plugin-libcss

This plugin will inject css into bundled js file using import statement like this:

// bundled js file, with import css at top (if any)
import './style.css';
// rest of the file
// ...

Install:

npm i vite-plugin-libcss -D

Usage:

// vite.config.js
import libCss from 'vite-plugin-libcss';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    // any other plugins
    libCss()
  ],
});

or with include/exclude options

// vite.config.js
import libCss from 'vite-plugin-libcss';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    // any other plugins
    libCss({
      include: 'src/**/*', // Include all entry files
      exclude: 'src/utils/*', // Exclude entry files in the "utils" directory
    })
  ],
});

Note that this plugin will only work with library-mode and es format build.