🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

vite-plugin-import-css-sheet

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-import-css-sheet

Small plugin that enables the use of tc39/proposal-import-attributes for css files in vite.

1.0.9
latest
npm
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

vite-plugin-import-css-sheet

Small plugin that enables the use of tc39/proposal-import-attributes for css files in vite.
Any imported .css file that uses the with/assert syntax will be imported as a CSSStyleSheet.
This plugin only covers .css imports and nothing else.

Install

npm

npm i vite-plugin-import-css-sheet --save-dev

pnpm

pnpm add -D vite-plugin-import-css-sheet

Enable

import { defineConfig } from 'vite';
import { viteImportCssSheet } from 'vite-plugin-import-css-sheet';

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

For typings to work correctly, in your tsconfig.json file add the following:

tsconfig.json

{
	"compilerOptions": {
		"types": [
			"vite-plugin-import-css-sheet/client"
		]
	},
}

This adds the correct type to .css file imports.

If you also use vite/client typings, vite-plugin-import-css-sheet/client must be below it.

Usage

New correct syntax.

import style from './button.css' with { type: 'css' };

Also works with the previous assert syntax.

import style from './button.css' assert { type: 'css' };



FAQs

Package last updated on 19 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts