JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6985
  • Score
    100M100P100Q129001F
  • License MIT

This plugin will inject css into bundled js file using `import` statement.

Package Exports

  • vite-plugin-libcss
  • vite-plugin-libcss/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (vite-plugin-libcss) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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.