Marc Casavant
Marc Casavant

Reputation: 299

Why won't grunt run my task?

I'm attempting to use the grunt-email-inliner module and for some reason it doesn't appear to be running. I'm new to grunt, what am I missing? I triple checked the docs.

Here is a link to the plugin: https://github.com/yargalot/Email-Builder

module.exports = function(grunt) {
  grunt.initConfig({

    emailBuilder: {
      test: {
        files: [{
          expand: true,
          cwd: 'web/src/vm-templates',
          src: ['*.html'],
          dest: 'web/src/result/',
          ext: '.vm',
        }]
      }
    },
    less: {
      development: {
        options: {
          //compress: true,
          //yuicompress: true,
          //optimization: 2
        },
        files: {
          // target.css file: source.less file
          "WebContent/css/styles.css": "less/styles.less"
        }
      }
    },
    watch: {
      styles: {
        files: ['less/**'], // which files to watch
        tasks: ['less'],
        options: {
          nospawn: true
        }
      }
    }

  });

  grunt.loadNpmTasks('grunt-email-builder');
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.registerTask('default', ['less']);
  grunt.registerTask('default', ['less', 'watch', 'emailBuilder']);

};

Upvotes: 1

Views: 133

Answers (2)

Seth
Seth

Reputation: 10454

It's not running because you're declaring watch before you declare emailBuilder. watch fires and starts polling for changes before the emailbuilder can ever get a chance to run. Quadruple check next time.

After reorder:

grunt.registerTask('default', ['less', 'emailBuilder', 'watch']); // correct

correct

Before reorder:

grunt.registerTask('default', ['less', 'watch', 'emailBuilder']); // Incorrect

incorrect

Also, you're defining a default task twice:

grunt.registerTask('default', ['less']);
grunt.registerTask('default', ['less', 'watch', 'emailBuilder']);

Drop the first one.

Upvotes: 1

Seva Arkhangelskiy
Seva Arkhangelskiy

Reputation: 685

Try changing src: ['*.html'] to src: ['**/*.html']

Upvotes: 0

Related Questions