【问题标题】:Warning: Task "default" not found警告:未找到任务“默认”
【发布时间】:2016-02-10 03:31:12
【问题描述】:

这是我的Gruntfile.js

module.exports = function(grunt) {
  require('logfile-grunt')(grunt, {
    filePath: './logs/grunt.log',
    clearlogFile: true
  });
  grunt.initConfig({
    // pkg: grunt.file.readJSON('package.json'),
    connect: {
      server: {
        options: {
          port: 9001,
          hostname: '*',
          middleware: function(connect, options) {
            return [
              function(req, res, next) {
                res.setHeader('X-UA-Compatible', 'IE-edge');
                next();
              }
              connect.static('project')
            ]
          }
        }
      }
    },
    watch: {
      options: {
        livereload: true
      },
      files: ['project/**/*.js', 'project/**/*.html', 'project/**/*.css'],
      task: []
    }
  });

  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.registerTask('default', ['connect:server', 'watch']);
};

【问题讨论】:

  • 我知道它与您的答案不太相符,但还有一些其他的捆绑器/任务运行器与 angular 一起使用,这使得开发服务器和 env 的使用方式比 grunt 或 gulp 更容易。比如 Webpack 或 Browserify。

标签: angularjs gruntjs gruntfile


【解决方案1】:

你忘了在返回数组中写昏迷

return [
    function(req, res, next) {
        res.setHeader('X-UA-Compatible', 'IE-edge');
        next();
     },
     connect.static('project')
]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-08-27
    • 2023-04-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多