Skip to content

sapegin/postcss-inject

 
 

Repository files navigation

Build Status

PostCSS Inject

PostCSS Inject is PostCSS plugin that can inject one css file to another.

Why?

Let's say there are some css variables that are required in few separet css files which don't import each other so they can not inherit variables. To make variables work across all css files you need to:

  • import all css files into each other
  • import variables in each css file where variables required

Basic Usage

postcss([
	require('postcss-inject')({
		cssFilePath: 'path/to/file/'
	})
]);

variables.css:

:root {
	--primary-color: green;
	--scondary-color: blue;
}

input.css:

a {
	color: var(--primary-color);
}

a:hover {
	color: var(--secondary-color);
}

output.css:

:root {
	--primary-color: green;
	--scondary-color: blue;
}

a {
	color: var(--primary-color);
}

a:hover {
	color: var(--secondary-color);
}

Options

Name Description
injectTo Use fileStart to inject at the begining of file
cssPlainText Plain CSS for example /* My CSS File */
cssFilePath Path to css file

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 98.4%
  • CSS 1.6%