Refactor postcss.js
Decoupled import routine from final export to provide a shared instance of the PostCSS processor and for easier readability of file.
This commit is contained in:
@@ -1,19 +1,14 @@
|
|||||||
/**
|
/**
|
||||||
* If available, create the PostCSS processor with any plugins.
|
* @file If available, returns 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) {
|
try {
|
||||||
return postcss([ autoprefixer ]);
|
var { default: postcss } = await import('postcss');
|
||||||
}
|
let { default: autoprefixer } = await import('autoprefixer');
|
||||||
} catch (err) {
|
|
||||||
// swallow this error; postcss and plugins are optional.
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
postcss = postcss([ autoprefixer ]);
|
||||||
})();
|
} catch (err) {
|
||||||
|
postcss = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default postcss;
|
||||||
|
|||||||
Reference in New Issue
Block a user