Grunt在8000端口运行,我不知道为什么

时间:2013-11-15 17:33:45

标签: javascript gruntjs

这是我的Gruntfile.js

module.exports = function(grunt) {

  require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

  grunt.initConfig({
    dirs: {
      js: ['app/js/**/*.js', '!app/js/libs/**/*.js'],
      jshint: ['Gruntfile.js','app/js/**/*.js','!app/js/libs/**/*.js'],
      html: ['app/index.html'],
      css: ['app/styles/**/*.css'],
      less: ['app/styles/**/*.less'],
      tests: ['test/**/*.js']
    },
    hbs: {
      templateExtension : 'hbs'
    },
    connect:{
      development: {
        port: 9000,
        base: 'app',
        keepalive: true,
        livereload: true
      }
    }
  });

  grunt.registerTask('server', ['less', 'connect', 'watch', 'open:dev']);
};

当我启动服务器时,它在端口8000上运行。根据我的理解,我在connect:developement:port属性中指定端口。是什么让它在8000端口上运行? enter image description here

1 个答案:

答案 0 :(得分:3)

尝试将连接后缀更改为开发:

grunt.registerTask('server', ['less', 'connect:development', 'watch', 'open:dev']);

您可能还需要指定选项:

connect: {
    development: {
        options: {
            port: 9000,
            base: 'app',
            keepalive: true,
            livereload: true
        }
    }
}