Postcss plugin for auto generating code
$ npm install postcss-parse-atrule-events --save
let result = require('postcss-parse-atrule-events').parse('code');
Input:
@on load {
@fetch my/async/styles1.css;
@fetch my/async/styles1.css;
}
.my-critical-path-selector {
width: 100px;
height: 100px;
}
Output:
let output = [
{
attachOn: "load",
imports: [
"my/async/styles1.css",
"my/async/styles1.css"
],
styles: "",
type: "on",
},
{
attachOn: "immediately",
imports: [],
styles: ".my-critical-path-selector { width: 100px; height: 100px; }",
type: "default",
},
];
git clone https://github.com/SerkanSipahi/app-decorators.git
cd app-decorators/packages/postcss-parse-atrule-events
npm run test