Search code examples
gruntjsuncss

UNCSS keeps aborting with "src files were empty" message


I keep getting this error with UNCSS: 'Warning: Destination (dist/css/main.css) not written because src files were empty. Use --force to contine. Aborted due to warnings.

I believe it's running the task fine and is set up properly. I can use grunt for other things.

In gruntfile.js, I've included: grunt.loadNpmTasks('grunt-uncss'); and

  uncss: {
    dist: {
        files: {
          'dist/css/main2.css': ['../index.html']                                           
        }
    }
  }

I'm not sure what's wrong, but I think it's the pathing, but that's just how it is. I'm also using SCSS, so maybe it needs a raw css as SRC? I've tried reinstalling PhantomJS and the raw UNCSS without Grunt, but I'm going no where! Any ideas?


Solution

  • I found the solution. It wasn't necessarily the pathing, but how the pathing was presented.

    I was using

      files: {
          'dist/css/main2.css': ['../index.html']                                           
      }
    

    I switched to

     files: [       
          { src: 'index.html', dest: 'dist/css/main.css' }
     ]
    

    Here, the src & dest are declared.

    This blog helped me deanhume.com. The github/NPM documentation didn't work for me, but this guy's did. I hope this helps someone!