FullHuman / grunt-purgecss

Grunt plugin for purgecss
MIT License
9 stars 2 forks source link

Whitelist option not ignoring class #7

Open yanodnoralov opened 5 years ago

yanodnoralov commented 5 years ago

Using "whitelist" option to ignore certain classes isn't working -- purgecss still removes those classes. Am I doing something wrong or is this a bug? Running grunt-purgecss 1.0.0, and grunt 1.0.3.

`module.exports = function(grunt) { grunt.initConfig({

    purgecss: {
      my_target: {
        options: {
          content: ['page-templates/home-page.php'],
          whitelist: ['random', 'text-white', 'button']
        },
        files: {
          'build/css/style-home-purge.css': ['source/sass/style-combined.css']
        }
      }
    }

});

grunt.loadNpmTasks('grunt-purgecss');

}`

hermanndettmann commented 5 years ago

Same problem here. Any updates on this issue?

Edd-G commented 5 years ago

Confirm. It seems that the parameters are not passed to purgecss. In task/purgecss.js pass only content and css options.

As workaround, you can whitelist directly in your CSS with a special comment. https://www.purgecss.com/whitelisting

eness commented 5 years ago

As a temporary solution who needs to enable any options of PurgeCSS, pass parameters you wish directly to the PurgeCSS options from the file node_modules/grunt-purgecss/tasks/purgecss.js line #30

      var purgecssResult = new Purgecss({
        content: options.content,
        **extractors: options.extractors,
        whitelist: options.whitelist,**
        css: src
      }).purge()[0].css