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.
20 lines
503 B
JavaScript
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;
|
|
})();
|