Grunt - nodemon + watch

时间:2015-09-17 11:15:17

标签: gruntjs grunt-contrib-watch nodemon grunt-contrib-sass grunt-concurrent

我是咕噜咕噜咕噜咕噜咕噜咕噜咕噜咕噜咕噜咕噜咕噜咕噜咕噜咕噜咕噜咕......我使用angular-client-side-auth作为我的单页应用程序,我想将grunt-contrib-sass和grunt-contrib-watch添加到Gruntfile.js中。这就是问题,当我使用nodemon启动服务器时,手表永远不会运行。我试过并发,但没有运气。

这是我的Gruntfile.js:

module.exports = function(grunt) {

  // Load tasks
  grunt.loadNpmTasks('grunt-concurrent');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-sass');
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.loadNpmTasks('grunt-mocha-test');
  grunt.loadNpmTasks('grunt-env');
  grunt.loadNpmTasks('grunt-nodemon');
  grunt.loadNpmTasks('grunt-contrib-clean');

  //require('load-grunt-tasks')(grunt); // npm install --save-dev load-grunt-tasks
  grunt.initConfig({
      mochaTest: {
          test: {
            options: {
                reporter: 'spec'
            },
            src: ['server/tests/**/*.js']
          }
      },
      env : {
        options : {
          //Shared Options Hash
        },
        dev : {
            NODE_ENV : 'development'
        },
        test : {
            NODE_ENV : 'test'
        }
    },

    nodemon: {
        dev: {
            script: 'server.js',
        }
    },
     watch: {
        //options: { nospawn: true, livereload: true },
        sass: {
            files: ["client/css/styles.sass"],
            tasks: ['sass'],
        },
        cssmin: {
            files: ["client/css/styles.sass"],
            tasks: ['cssmin'],
        }
    },
    sass: {
        dist: {
            files: {
                'client/css/styles.css':  'client/css/styles.scss'
            }
        }
    },
    cssmin: {
      options: {
        shorthandCompacting: false,
        roundingPrecision: -1
      },
      target: {
        files: [{
          expand: true,
          cwd: 'client/css',
          src: ['styles.css', '!*.min.css'],
          dest: 'client/css',
          ext: '.min.css'
        }]
      }
    },
    concurrent: {
      dev: {
        options: {
          logConcurrentOutput: true
        },
        tasks: ['watch', 'nodemon:dev']
      }
    },

    clean: ["node_modules", "client/components"]

  });

  grunt.registerTask('serverTests', ['env:test', 'mochaTest']);
  grunt.registerTask('test', ['env:test', 'serverTests']);
  grunt.registerTask('dev', ['env:dev', 'concurrent:dev']);
};

0 个答案:

没有答案