diff --git a/plugins/postcss-custom-properties/src/lib/get-custom-properties-from-root.ts b/plugins/postcss-custom-properties/src/lib/get-custom-properties-from-root.ts index e177478fa..79e8285dc 100644 --- a/plugins/postcss-custom-properties/src/lib/get-custom-properties-from-root.ts +++ b/plugins/postcss-custom-properties/src/lib/get-custom-properties-from-root.ts @@ -1,5 +1,5 @@ import valuesParser from 'postcss-value-parser'; -import { isBlockIgnored } from './is-ignored'; +import { isBlockIgnored, hasIgnoreComment } from './is-ignored'; // return custom selectors from the css root, conditionally removing them export default function getCustomPropertiesFromRoot(root, opts): Map { @@ -8,6 +8,9 @@ export default function getCustomPropertiesFromRoot(root, opts): Map = new Map(); const out: Map = new Map(); + + const isIgnoreCommentInFile = root.source && hasIgnoreComment(root.source.input.css); + // for each html or :root rule root.nodes.slice().forEach(rule => { const customPropertiesObject = isHtmlRule(rule) @@ -19,7 +22,7 @@ export default function getCustomPropertiesFromRoot(root, opts): Map { - if (decl.variable && !isBlockIgnored(decl)) { + if (decl.variable && (!isIgnoreCommentInFile || !isBlockIgnored(decl))) { const { prop } = decl; // write the parsed value to the custom property @@ -33,7 +36,7 @@ export default function getCustomPropertiesFromRoot(root, opts): Map