1

我是 grunt 的新手,所以我猜我在做一些简单的事情真的错了。我正在为我的单页应用程序使用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']);
};
4

0 回答 0