• Resolved lucius100

    (@lucius100)


    So I already made my custom theme, but my style.css is a bit bloated, because I copied from other sources. And I want to remove unused css with purgecss.

    My theme structure
    wp-content/themes/*.php
    wp-content/themes/style.css
    wp-content/themes/assets/*.js
    wp-content/themes/assets/*.css

    I just want to trim style.css
    Inside folder assets only bootstrap css, I don’t know if purgecss can trim that or not.
    I already installed purgecss in dev, here is my package.json

    "devDependencies": {
        "purgecss": "^4.0.3",
        "purgecss-with-wordpress": "^4.0.3"
      }

    From what I read in the documentation, I need to use configuration file, and use CLI to output the trimmed style.css
    How to do that ? My current configuration at purgecss.config.js

    import PurgeCSS from 'purgecss'
    import purgecssWordpress from 'purgecss-with-wordpress'
    
    const purgeCSSResults = await new PurgeCSS().purge({
        content: ['*.php'],
        css: ['style.css', 'assets/*.css'],
        safelist: purgecssWordpress.safelist,
        safelistPatterns: purgecssWordpress.safelistPatterns
    })

    Is that correct already ? So I just run purgecss –config ./purgecss.config.js ?
    How to specify output ? I don’t want to overwrite the existing style.css

    • This topic was modified 4 years, 9 months ago by lucius100.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator t-p

    (@t-p)

    I already installed purgecss

    purgecss could not be found in the ww.wp.xz.cn/plugins/ directory, as far as I can see.

    If you use a commercial plugin and need support, please go to their official support channel. In order to be good stewards of the WordPress community, and encourage innovation and progress, we feel it’s important to direct people to those official locations: https://purgecss.com/

    Commercial products are not supported in these forums.

    Thread Starter lucius100

    (@lucius100)

    @t-p That’s free product, not commercial product, you can see their open source code in github. I thought it was related to wordpress so I can ask it here since it’s more like wordpress configuration cases.
    Well, if it’s not supported here, you may close this thread, thanks.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘How to purgecss with wordpress ?’ is closed to new replies.