Files
OfficialSite/build/utils/postcss.js
Chauncey McAskill 454ae64d07 Make postcss optional in styles.js
Added:
- Utility 'postcss.js' to use dynamic imports to fetch PostCSS and Autoprefixer, if available, and build the Processor object.
- Function `saveStylesheet()` in 'styles.js' to decouple the writing of CSS files and source maps.
- Condition to process with PostCSS if it's available.
2021-09-18 01:16:44 -04:00

20 lines
503 B
JavaScript

/**
* If available, create the PostCSS processor with any plugins.
*
* @type {?module:postcss~Processor}
*/
export default await (async () => {
try {
const { default: postcss } = await import('postcss');
const { default: autoprefixer } = await import('autoprefixer');
if (postcss && autoprefixer) {
return postcss([ autoprefixer ]);
}
} catch (err) {
// swallow this error; postcss and plugins are optional.
}
return null;
})();