gruntjs / grunt-contrib-watch

Run tasks whenever watched files change.
http://gruntjs.com/
MIT License
1.98k stars 356 forks source link

jade4hphp + watch #478

Closed ghost closed 8 years ago

ghost commented 8 years ago

Hello there,

how can I watch this jade4php code:

module.exports = function(grunt) {

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    clean: {
      compile: ['app/views/**/*.phtml'],
    },
    jade4php: {
      compile: {
        options: {
          pretty: true
        },
        expand: true,
        cwd: 'public/jade',
        src: ['**/*.jade', '!_**/*.jade', '!layout/*.jade', '!mixins/*.jade', '!includes/*.jade'],
        dest: 'app/views/',
        ext: '.phtml'
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-jade4php');

  grunt.registerTask('default', ['clean','jade4php']);

};
poolghost commented 8 years ago

first run:

(sudo) npm install grunt-contrib-watch --save-dev

than include watch in your Gruntfile.js

module.exports = function(grunt) {

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    clean: {
      compile: ['app/views/**/*.phtml'],
    },
    jade4php: {
      compile: {
        options: {
          pretty: true
        },
        expand: true,
        cwd: 'jade',
        src: ['**/*.jade', '!_**/*.jade', '!layout/*.jade', '!mixins/*.jade', '!includes/*.jade'],
        dest: 'htdocs/templates/',
        ext: '.phtml'
      }
    },
    watch: {
      jade: {
        files: ['**/*.jade'],
        tasks: ['jade4php'],
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-jade4php');
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.registerTask('default', ['clean','jade4php']);

};

activate watch

grunt watch
poolghost commented 8 years ago

update: change

dest: 'htdocs/templates/',