Style Inject
Inject component styles from files
For each input component read a file containing all component styles and overwrite the output styles for the component, designed to be used with files created by style-extract.
Files are read from the directory specified using the dir
option, if a file is not found for a given component no modification of the styles is performed otherwise the styles for the component are removed and replaced with styles from the file.
Install
npm i trucks-transform-style-inject --save-dev
For the command line interface see trucks-cli.
Usage
Use the style-inject
key to configure this transform:
const trucks = require('trucks');
trucks(
{
files: ['components.html'],
transforms: ['style-inject'],
conf: {
transforms: {
'style-inject': {
dir: 'src/components/css'
}
}
}
}, (err, res) => {
if(err) {
throw err;
}
console.log(res);
}
);
API
inject
public inject(state, conf)
Inject component styles from files.
Returns map of visitor functions.
-
state
Object compiler state. -
conf
Object transform plugin configuration.
Options
-
dir
String input directory.
License
MIT
Created by mkdoc on July 19, 2016