5

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!

pedrommuller
  • 15,741
  • 10
  • 76
  • 126

1 Answers1

0

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

jth_92
  • 1,120
  • 9
  • 23
  • My problem is that ignoreSheets is not working. I'm trying to ignore index.css, and my ignoreSheets line looks like this: `ignoreSheets : [/index/],`. But it does nothing. Path shouldn't matter, because it's just matching the word "index". – felwithe Jul 09 '15 at 18:45