0

New to grunt I have successfully used it to run purifycss. Now I want to run purifycss twice with different arguments, and ideally concat the two resulting files afterwards. What I have so far is this Gruntfile:

module.exports = function(grunt) {

  grunt.initConfig({
    purifycss: {
      bootstrap: {
        options: {},
        target: {
              src: [ 'live/*.twig' ],
              css: ['live/css/bootstrap*.css'],
              dest: 'purified_bootstrap.css'
                }
            },
      mycss: {
        options: {},
        target: {
              src: [ 'live/*.twig' ],
              css: ['live/css/mycss.css'],
              dest: 'purified_mycss.css'
                }
            }
      }
  });

  grunt.loadNpmTasks('grunt-purifycss');
  grunt.registerTask('purify', ['purifycss:bootstrap', 'purifycss:mycss']);
};

The output I get when running grunt purify from terminal:

> grunt purify
Running "purifycss:bootstrap" (purifycss) task
Warning: Cannot call method 'forEach' of undefined Use --force to continue.
Aborted due to warnings.

Any help on what's going wrong here appreciated!

Jordan Kasper
  • 13,153
  • 3
  • 36
  • 55
Chransen
  • 41
  • 4
  • Are you sure that the `src` and `css` options are actually files that exist? It's hard to say why this fails without seeing the directory structure – Jordan Kasper Apr 17 '17 at 19:37
  • Thanks for your reply! Yes, running both tasks seperately works just fine. – Chransen Apr 17 '17 at 19:41
  • @jakerella directory structure is folder where grunt lives, /live where a set of twig templates sit and finally live/css where the css files are. So **folder/live/css** – Chransen Apr 17 '17 at 19:51
  • Maybe the purifycss plugin is having an issue running both because the first one alters the array for files in `live/css/` and then the second task can't read it? Not sure... – Jordan Kasper Apr 17 '17 at 20:04
  • You might want to run: `grunt purify --verbose` – Jordan Kasper Apr 17 '17 at 20:04
  • @jakerella runing verbose gives `Initializing Command-line options: --verbose Reading "Gruntfile.js" Gruntfile...OK Registering Gruntfile tasks. Initializing config...OK Registering "grunt-purifycss" local Npm module tasks. Reading /home/uk/dev/sites/shg/node_modules/grunt-purifycss/package.json...OK Parsing /home/uk/dev/sites/shg/node_modules/grunt-purifycss/package.json...OK Loading "purifycss.js" tasks...OK + purifycss Loading "Gruntfile.js" tasks...OK + purify ` – Chransen Apr 17 '17 at 20:33
  • and then `Running tasks: purify Running "purify" task Running "purifycss:bootstrap" (purifycss) task Verifying property purifycss.bootstrap exists in config...OK File: [no files] Options: write=false, info Warning: Cannot call method 'forEach' of undefined Use --force to continue. Aborted due to warnings. ` – Chransen Apr 17 '17 at 20:33
  • Hmm... Looks like it couldn't find any files the second time through... not sure why though – Jordan Kasper Apr 17 '17 at 20:44
  • I think you should post this as an issue on the GitHub repo for that plugin: https://github.com/purifycss/grunt-purifycss – Jordan Kasper Apr 17 '17 at 20:44
  • Thanks @jakerella – Chransen Apr 17 '17 at 21:16

0 Answers0