0

I was introduced to Node.js today and built a very simple Hello, World app. I also started using grunt to automate builds and deployments.

I am using the Bootstrap framework and colors.css.

<div class="hello"><h1>Hello, World</h1></div>

I add a few color classes to some elements using jQuery.

console.log('dev mode');
$('.hello').addClass('bg-blue');

I run the code through grunt-uncss.

uncss: {
    dist: {
        files: {
            'dist/styles.min.css': 'index.html'
        }
    }
}

But none of the color classes including bg-blue are there in styles.min.css.

If I don't run the file through uncss, everything works as expected.

What am I doing wrong?

duci9y
  • 4,128
  • 3
  • 26
  • 42

1 Answers1

1

Try using the timeout option. It allows you to wait for the JS to load and execute. See the option here - https://github.com/addyosmani/grunt-uncss/issues/1

uncss: {
    dist: {
       options : {
           timeout: 2000
       },
       files: {
            'dist/styles.min.css': 'index.html'
        }
    }
}

Also take a look at this discussion - https://github.com/addyosmani/grunt-uncss/issues/1

Ankur Anand
  • 535
  • 2
  • 9