Uncss Ignore option isn't working

1.7k views Asked by At

I'm trying remove the css with uncss but it's removing all the styles no matter if they are listed on the ignore array.

The 2 files that I want to compare are just the index and the app.min.js which contains all the templates embedded in the javascript as strings, which are configured using $templateCache

take a look to the grunt task maybe there is something obvious that I'm missing:

uncss:{
    production: {
        options: {
            ignore: ['.someclass', '.someclass', '.someclass','.etc_etc_class'],
            stylesheets:['app.min.css']
        },
        files: {
            'dist/app.min.css':['dist/index.html','dist/app.min.js']
        }        
    }
}

any comment will be more than welcome!

1

There are 1 answers

1
jth_92 On

The stylesheets option should have the full path of the css files relative to the root directory. So if the file is in dist/ add that to the stylesheets option.

For example:

uncss: {
  dist: {
    options: {
      ignore       : ['#added_at_runtime', /test\-[0-9]+/],
      media        : ['(min-width: 700px) handheld and (orientation: landscape)'],
      raw          : 'h1 { color: green }',
      stylesheets  : ['lib/bootstrap/dist/css/bootstrap.css', 'src/public/css/main.css'],
      ignoreSheets : [/fonts.googleapis/],
      urls         : ['http://localhost:3000/mypage', '...'], // Deprecated
      timeout      : 1000,
      htmlroot     : 'public',
      report       : 'min'
    },
    files: {
      'dist/css/tidy.css': ['app/index.html', 'app/about.html']
    }
  }
}

See: https://github.com/addyosmani/grunt-uncss