-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Run PostCSS synchronously? #1328
Copy link
Copy link
Closed
Description
I am writing my own node script for development. I am facing a problem where PostCSS processes the files asynchronously and the server starts before the compilation is complete.
I know it should return a LazyResult, is there a way to not do that? This is my code:
const processCSS = () => {
const CSSFile = fs.readFileSync(path.resolve(__dirname, '../src/styles/main.css'));
postcss(postcssConfig.plugins)
.process(CSSFile, { from: 'src/styles/main.css', to: '.tmp/styles/main.css' })
.then(result => {
fs.writeFileSync('.tmp/styles/main.css', result.css, () => true);
logInfo('CSS', 'steelblue', 'Processed successfully');
if ( result.map ) {
fs.writeFileSync('.tmp/styles/main.css', result.map, () => true);
}
})
.catch(err => {
});
}
processCSS();I tried switching to async/await without success. I've seen this old issue and I still have no clue what should be done.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels