1.0.2 • Published 5 years ago

postcss-inject v1.0.2

Weekly downloads
359
License
MIT
Repository
github
Last release
5 years ago

Build Status

PostCSS Inject

Why?

Let's say there are some css variables that are required in few separate 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

NameDescription
injectToUse fileStart to inject at the begining of file
cssPlainTextPlain CSS for example /* My CSS File */
cssFilePathPath to css file