vite-inject-css
TypeScript icon, indicating that this package has built-in type declarations

3.1.0 • Public • Published

vite-inject-css

A Vite plugin that takes the CSS and injects it via JS using CSSStyleSheet.insertRule()

This was inspired by React Native's StyleSheet, the <style> tag injected to the header doesn't have anything inside when viewed through inspect element

Installation

yarn add -D vite-inject-css

Usage

import injectCSS from "vite-inject-css";

export default {
    plugins: [injectCSS()],
};

Config

When you add the plugin, you can provide an optional config object.

obfuscate

If you want extra obfuscation of the CSS rules, with the downside of a bigger bundle size, set obfuscate to true

import injectCSS from "vite-inject-css";

export default {
    plugins: [injectCSS({ obfuscate: true })],
};

/vite-inject-css/

    Package Sidebar

    Install

    npm i vite-inject-css

    Weekly Downloads

    5

    Version

    3.1.0

    License

    MIT

    Unpacked Size

    15 kB

    Total Files

    19

    Last publish

    Collaborators

    • stasadance