1
0
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:
Chauncey McAskill
2022-03-29 21:08:48 -04:00
parent 0738dd6491
commit 9d758f3b2c
2 changed files with 8 additions and 3 deletions

View File

@@ -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,

View File

@@ -15,6 +15,8 @@ try {
// do nothing
}
export const supportsPostCSS = (typeof postcss === 'function');
export default postcss;
export const pluginsList = [
autoprefixer,