Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wxsms/vite-plugin-libcss
This plugin will inject css into bundled js file using import statement.
https://github.com/wxsms/vite-plugin-libcss
css plugins vite
Last synced: 3 months ago
JSON representation
This plugin will inject css into bundled js file using import statement.
- Host: GitHub
- URL: https://github.com/wxsms/vite-plugin-libcss
- Owner: wxsms
- License: mit
- Created: 2021-12-22T04:51:34.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-03-01T06:26:24.000Z (11 months ago)
- Last Synced: 2024-04-24T01:22:04.848Z (9 months ago)
- Topics: css, plugins, vite
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/vite-plugin-libcss
- Size: 20.5 KB
- Stars: 46
- Watchers: 3
- Forks: 6
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# vite-plugin-libcss
This plugin will inject css into bundled js file using `import` statement like this:
```js
// 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:
```js
// 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
```js
// 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](https://vitejs.dev/guide/build.html#library-mode) and es format build.