0

I've tried to configure uncss using grunt

I've installed

npm install grunt-uncss --save-dev
npm install grunt-processhtml --save-dev

Configuration

uncss: {
    dist: {
        files: { 'dist/css/clean.css': ['index.php'] }
    }
}

at the end I load them in and register a default task like this :

grunt.loadNpmTasks('grunt-uncss');
grunt.loadNpmTasks('grunt-processhtml');

grunt.registerTask('default', ['uncss', 'processhtml']);

Result

When I run grunt

at the end I keep seeing :

Running "uncss:dist" (uncss) task

Fatal error: PhantomJS: Cannot open about:blank


Update

I added :

processhtml: {

    dist: {

        files: {

            'index.php': ['index.php']
        }
    }
}

Still get the same error after running grunt

Community
  • 1
  • 1
code-8
  • 54,650
  • 106
  • 352
  • 604

2 Answers2

1

If this is all of your code, you are not referencing any stylesheets to remove code from. All you are doing is telling grunt where the cleaner file should go, and to remove any unused css from index.php. However, it doesn't know where the styles for index.php live, so it has nothing to do... You need to actually configure your processhtml and tell uncss which stylesheets you would like to clean up.

Read the directions friend:

grunt-uncss github readme.md

Jakob Vendegna
  • 110
  • 1
  • 7
  • I added the configure for processhtml, and still have the same error message. Did I still forget to do anything elses ? – code-8 May 18 '15 at 17:12
0

I have that problem with my project and the solution is here: You need update the uncss module, remember grunt-uncss is only a way to use uncss node package. In my case my version of that was in 0.12.1 and updating that package the problem was fixed. Let me know if this help you.

fractefactos
  • 353
  • 4
  • 10