Skip to content

Instantly share code, notes, and snippets.

@TheDevMinerTV
Created August 29, 2024 21:45
Show Gist options
  • Save TheDevMinerTV/50a2ab2ae83d5787cceff2055c27bed6 to your computer and use it in GitHub Desktop.
Save TheDevMinerTV/50a2ab2ae83d5787cceff2055c27bed6 to your computer and use it in GitHub Desktop.
diff --git a/dist/index.cjs b/dist/index.cjs
index c51f4a286e33b44e7925b841babe7810307d8fe0..5e54de8149fb266568307fdf4a472721eb057bc0 100644
--- a/dist/index.cjs
+++ b/dist/index.cjs
@@ -228,11 +228,11 @@ const transformSelectorPostcssPlugin = function(options) {
root.walkRules((rule) => {
parser__default((selectors) => {
selectors.walkClasses((s) => {
- if (s.value && replaceMap && replaceMap.has(s.value)) {
+ if (s.value && replaceMap && replaceMap[s.value]) {
if (ignoreVueScoped && isVueScoped(s)) {
return;
}
- const v = replaceMap.get(s.value);
+ const v = replaceMap[s.value];
if (v) {
if (ctx.isPreserveClass(s.value)) {
rule.cloneBefore();
@@ -254,6 +254,12 @@ transformSelectorPostcssPlugin.postcss = true;
async function cssHandler(rawSource, options) {
const acceptedPlugins = [transformSelectorPostcssPlugin(options)];
const { id } = options;
+ if (rawSource === '// extracted by mini-css-extract-plugin') {
+ return {
+ code: '/* empty */',
+ map: null
+ };
+ }
const { css: code, map } = await postcss__default(acceptedPlugins).process(rawSource, {
from: id,
to: id
diff --git a/dist/index.mjs b/dist/index.mjs
index a8d7832f085e7de493da83837fc37b34868d3a1f..80c013d32f0133f4f343eae3cf5171daf94d129c 100644
--- a/dist/index.mjs
+++ b/dist/index.mjs
@@ -218,11 +218,11 @@ const transformSelectorPostcssPlugin = function(options) {
root.walkRules((rule) => {
parser((selectors) => {
selectors.walkClasses((s) => {
- if (s.value && replaceMap && replaceMap.has(s.value)) {
+ if (s.value && replaceMap && replaceMap[s.value]) {
if (ignoreVueScoped && isVueScoped(s)) {
return;
}
- const v = replaceMap.get(s.value);
+ const v = replaceMap[s.value];
if (v) {
if (ctx.isPreserveClass(s.value)) {
rule.cloneBefore();
@@ -244,6 +244,12 @@ transformSelectorPostcssPlugin.postcss = true;
async function cssHandler(rawSource, options) {
const acceptedPlugins = [transformSelectorPostcssPlugin(options)];
const { id } = options;
+ if (rawSource === '// extracted by mini-css-extract-plugin') {
+ return {
+ code: '/* empty */',
+ map: null
+ };
+ }
const { css: code, map } = await postcss(acceptedPlugins).process(rawSource, {
from: id,
to: id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment