mirror of
https://github.com/locomotivemtl/locomotive-boilerplate.git
synced 2026-01-15 00:55:08 +08:00
Improve postcss.js
Added constant `supportsPostCSS` to provide a boolean to check if PostCSS is available.
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import loconfig from '../utils/config.js';
|
||||
import message from '../utils/message.js';
|
||||
import notification from '../utils/notification.js';
|
||||
import postcss, { pluginsMap as postcssPluginsMap } from '../utils/postcss.js';
|
||||
import postcss, {
|
||||
pluginsMap as postcssPluginsMap,
|
||||
supportsPostCSS
|
||||
} from '../utils/postcss.js';
|
||||
import resolve from '../utils/template.js';
|
||||
import { writeFile } from 'node:fs/promises';
|
||||
import { basename } from 'node:path';
|
||||
@@ -85,7 +88,7 @@ export default async function compileStyles(sassOptions = null, postcssOptions =
|
||||
sassOptions = Object.assign({}, defaultSassOptions, sassOptions);
|
||||
}
|
||||
|
||||
if (postcss) {
|
||||
if (supportsPostCSS) {
|
||||
if (postcssOptions == null) {
|
||||
postcssOptions = productionPostCSSOptions;
|
||||
} else if (
|
||||
@@ -116,7 +119,7 @@ export default async function compileStyles(sassOptions = null, postcssOptions =
|
||||
outFile: outfile,
|
||||
}));
|
||||
|
||||
if (postcss && postcssOptions) {
|
||||
if (supportsPostCSS && postcssOptions) {
|
||||
if (typeof postcssProcessor === 'undefined') {
|
||||
postcssProcessor = createPostCSSProcessor(
|
||||
postcssPluginsMap,
|
||||
|
||||
@@ -15,6 +15,8 @@ try {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
export const supportsPostCSS = (typeof postcss === 'function');
|
||||
|
||||
export default postcss;
|
||||
export const pluginsList = [
|
||||
autoprefixer,
|
||||
|
||||
Reference in New Issue
Block a user