Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting the enabled property of purgeCSS to true will invalidate the styles in the group #164

Closed
KeithChou opened this issue Feb 11, 2023 · 2 comments

Comments

@KeithChou
Copy link

KeithChou commented Feb 11, 2023

The question is mentioned in the title.

Here is package.json

{
  "name": "my-app",
  "scripts": {
    "webpack": "nuxt webpack --dev",
    "dev": "nuxt",
    "build": "nuxt build",
    "generate": "nuxt generate",
    "start": "nuxt start"
  },
  "dependencies": {
    "element-ui": "^2.15.12",
    "lodash": "^4.17.21",
    "nuxt": "2.15.8",
    "swiper": "4.3.5",
    "vant": "2.12.47",
    "vue-awesome-swiper": "3.1.3",
    "webpack": "4",
    "webpack-cli": "3.x"
  },
  "devDependencies": {
    "nuxt-purgecss": "^1.0.0",
    "nuxt-windicss": "^2.6.0"
  }
}

Here is my nuxt.config.js config

export default {
  /*
   ** Global CSS
   */
  css: [
    {
      src: 'element-ui/lib/theme-chalk/index.css',
    },
    {
      src: 'swiper/dist/css/swiper.css',
    },
    {
      src: 'vant/lib/index.css',
    },
  ],
  build: {
    extend(config, ctx) {
      if (ctx.isDev) {
        config.devtool = ctx.isClient ? 'source-map' : 'inline-source-map';
      }
    },
    extractCSS: {
      ignoreOrder: true,
    },
  },
  buildModules: ['nuxt-windicss', 'nuxt-purgecss'],
  purgeCSS: {
    enabled: true,
  },
};

Here is my template.

<template>
  <div class="sm:text-100px sm:(pl-4 pr-4)">
    Hello world!

    <div class="bg-yellow-100" @click="handleClick">windi css</div>
    <div class="bg-gray-200 w-100px box-border">self css</div>
  </div>
</template>

And the last one is windi.config.js

export default {
  preflight: false,
};

hen I set the enabled property of purgeCSS to true, which will invalidate the styles in the group. That is to say, sm:text-100px is available, but the sm:(pl-4 pr-4)can't work.
image

However, if I set it to false, everything is ok...!

{
purgeCSS: {
    enabled: false,
  },
}

image

Can anyone help me solve this issue?
Thank you a lot!

@manniL
Copy link
Member

manniL commented Feb 11, 2023

Because you use the group syntax, the classes "sm:pl-4" and "sm:pr-4" are not found by purgecss in the markup. You can whitelist the classes manually.

PS: Windicss should not need purgeCSS as they have their own extractors.

@manniL manniL closed this as not planned Won't fix, can't repro, duplicate, stale Feb 11, 2023
@KeithChou
Copy link
Author

Because you use the group syntax, the classes "sm:pl-4" and "sm:pr-4" are not found by purgecss in the markup. You can whitelist the classes manually.

PS: Windicss should not need purgeCSS as they have their own extractors.

Thank you for your answer! Let me refer to the relevant document of windicss 😆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants