Node.js 将express添加到GrunFile

Node.js 将express添加到GrunFile,node.js,express,coffeescript,gruntjs,yeoman,Node.js,Express,Coffeescript,Gruntjs,Yeoman,我想添加带有路线的express,当我运行grunt server时,这些路线会起作用。代码是用咖啡脚本写的,若你们不懂咖啡脚本,直接回答,我会重写。我尝试过grunt-express,grunt-express-server和其他许多方法,但都没有成功。这是我的文件 "use strict" LIVERELOAD_PORT = 35728 lrSnippet = require("connect-livereload")(port: LIVERELOAD_PORT) mountFolder =

我想添加带有路线的express,当我运行
grunt server
时,这些路线会起作用。代码是用咖啡脚本写的,若你们不懂咖啡脚本,直接回答,我会重写。我尝试过
grunt-express
grunt-express-server
和其他许多方法,但都没有成功。这是我的文件

"use strict"
LIVERELOAD_PORT = 35728
lrSnippet = require("connect-livereload")(port: LIVERELOAD_PORT)
mountFolder = (connect, dir) ->
    connect.static require("path").resolve(dir)
module.exports = (grunt) ->
    require("load-grunt-tasks") grunt
    require("time-grunt") grunt
    yeomanConfig =
        app: "client"
        dist: "dist"
    try
        yeomanConfig.app = require("./bower.json").appPath or yeomanConfig.app
    grunt.initConfig
        yeoman: yeomanConfig
        watch:
            coffee:
                files: ["<%= yeoman.app %>/scripts/**/*.coffee"]
                tasks: ["coffee:dist"]
            compass:
                files: ["<%= yeoman.app %>/styles/**/*.{scss,sass}"]
                tasks: ["compass:server"]
            livereload:
                options:
                    livereload: LIVERELOAD_PORT
                files: [
                    "<%= yeoman.app %>/views/**/*.html"
                ]
        connect:
            options:
                port: 9000
                hostname: "localhost"
            livereload:
                options:
                    middleware: (connect) ->
                        [lrSnippet, mountFolder(connect, ".tmp"), mountFolder(connect, yeomanConfig.app)]
            test:
                options:
                    middleware: (connect) ->
                        [mountFolder(connect, ".tmp"), mountFolder(connect, "test")]
            dist:
                options:
                    middleware: (connect) ->
                        [mountFolder(connect, yeomanConfig.dist)]
        open:
            server:
                url: "http://localhost:<%= connect.options.port %>"
        clean:
            dist:
                files: [
                    dot: true
                    src: [".tmp", "<%= yeoman.dist %>/*", "!<%= yeoman.dist %>/.git*"]
                ]
            server: ".tmp"
        jshint:
            options:
                jshintrc: ".jshintrc"
            all: ["Gruntfile.js", "<%= yeoman.app %>/scripts/**/*.js"]
        compass:
            options:
                sassDir: "<%= yeoman.app %>/styles"
                cssDir: ".tmp/styles"
                generatedImagesDir: ".tmp/styles/ui/images/"
                imagesDir: "<%= yeoman.app %>/styles/ui/images/"
                javascriptsDir: "<%= yeoman.app %>/scripts"
                fontsDir: "<%= yeoman.app %>/fonts"
                importPath: "<%= yeoman.app %>/bower_components"
                httpImagesPath: "styles/ui/images/"
                httpGeneratedImagesPath: "styles/ui/images/"
                httpFontsPath: "fonts"
                relativeAssets: true
            dist:
                options:
                    debugInfo: false
                    noLineComments: true
            server:
                options:
                    debugInfo: true
            forvalidation:
                options:
                    debugInfo: false
                    noLineComments: false
        coffee:
            server:
                options:
                    sourceMap: true
                    sourceRoot: ""
                files: [
                    expand: true
                    cwd: "<%= yeoman.app %>/scripts"
                    src: "**/*.coffee"
                    dest: ".tmp/scripts"
                    ext: ".js"
                ]
            dist:
                options:
                    sourceMap: false
                    sourceRoot: ""
                files: [
                    expand: true
                    cwd: "<%= yeoman.app %>/scripts"
                    src: "**/*.coffee"
                    dest: ".tmp/scripts"
                    ext: ".js"
                ]
        useminPrepare:
            html: "<%= yeoman.app %>/index.html"
            options:
                dest: "<%= yeoman.dist %>"
                flow:
                    steps:
                        js: ["concat"]
                        css: ["concat"]
                    post: []
        usemin:
            html: ["<%= yeoman.dist %>/**/*.html", "!<%= yeoman.dist %>/bower_components/**"]
            css: ["<%= yeoman.dist %>/styles/**/*.css"]
            options:
                dirs: ["<%= yeoman.dist %>"]
        htmlmin:
            dist:
                options: {}
                files: [
                    expand: true
                    cwd: "<%= yeoman.app %>"
                    src: ["*.html", "views/*.html"]
                    dest: "<%= yeoman.dist %>"
                ]
        copy:
            dist:
                files: [
                    expand: true
                    dot: true
                    cwd: "<%= yeoman.app %>"
                    dest: "<%= yeoman.dist %>"
                    src: [
                        "views/**/*"
                    ]
                ,
                    expand: true
                    cwd: ".tmp"
                    dest: "<%= yeoman.dist %>"
                    src: ["styles/**", "assets/**"]
                ,
                    expand: true
                    cwd: ".tmp/images"
                    dest: "<%= yeoman.dist %>/images"
                    src: ["generated/*"]
                ]
            styles:
                expand: true
                cwd: "<%= yeoman.app %>/styles"
                dest: ".tmp/styles/"
                src: "**/*.css"
        concurrent:
            server: ["coffee:server", "compass:server", "copy:styles"]
            dist: ["coffee:dist", "compass:dist", "copy:styles", "htmlmin"]
        concat:
            options:
                separator: grunt.util.linefeed + ';' + grunt.util.linefeed
            dist:
                src: ["<%= yeoman.dist %>/bower_components/angular/angular.min.js"]
                dest: "<%= yeoman.dist %>/scripts/vendor.js"
        uglify:
            options:
                mangle: false
            dist:
                files:
                    "<%= yeoman.dist %>/scripts/app.js": [".tmp/**/*.js"]
    grunt.registerTask "server", (target) ->
        return grunt.task.run(["build", "open", "connect:dist:keepalive"])  if target is "dist"
        grunt.task.run ["clean:server", "concurrent:server", "connect:livereload", "open", "watch"]
    grunt.registerTask "build", ["clean:dist", "useminPrepare", "concurrent:dist", "copy:dist", "concat", "uglify", "usemin"]
    grunt.registerTask "default", ["jshint", "build"]
“使用严格的”
LIVERELOAD_端口=35728
lrSnippet=require(“连接livereload”)(端口:livereload\u端口)
mountFolder=(连接,目录)->
connect.static require(“路径”).resolve(dir)
module.exports=(咕噜)->
需要(“加载grunt任务”)grunt
需要(“时间咕哝”)咕哝
约曼图=
应用程序:“客户端”
地区:“地区”
尝试
yeomanConfig.app=require(“./bower.json”).appPath或yeomanConfig.app
grunt.initConfig
约曼:约曼图
观察:
咖啡:
文件:[“/scripts/***/*.coffee”]
任务:[“咖啡区”]
指南针:
文件:[“/styles/***.{scss,sass}”]
任务:[“指南针:服务器”]
利弗雷罗德:
选项:
利弗雷洛德:利弗雷洛德港口
档案:[
“/views/***.html”
]
连接:
选项:
港口:9000
主机名:“本地主机”
利弗雷罗德:
选项:
中间件:(连接)->
[lrSnippet,mountFolder(connect,“.tmp”)、mountFolder(connect,yeomanConfig.app)]
测试:
选项:
中间件:(连接)->
[安装文件夹(连接“.tmp”)、安装文件夹(连接“测试”)]
地区:
选项:
中间件:(连接)->
[安装文件夹(连接,yeomanConfig.dist)]
开放式:
服务器:
url:“http://localhost:"
清洁:
地区:
档案:[
多特:是的
src:[“.tmp”、“/*”、“!/.git*”]
]
服务器:“.tmp”
jshint:
选项:
jshintrc:“.jshintrc”
全部:[“Gruntfile.js”,“/scripts/***/.js”]
指南针:
选项:
sassDir:“/styles”
cssDir:“.tmp/样式”
generatedImagesDir:“.tmp/styles/ui/images/”
imagesDir:“/styles/ui/images/”
javascriptsDir:“/scripts”
fontsDir:“/fonts”
导入路径:“/bower\u组件”
httpImagesPath:“样式/ui/images/”
httpGeneratedImagesPath:“样式/ui/images/”
httpFontsPath:“字体”
相对论:对
地区:
选项:
debugInfo:false
诺林评论:对
服务器:
选项:
debugInfo:true
验证:
选项:
debugInfo:false
noLineComments:错误
咖啡:
服务器:
选项:
sourceMap:true
sourceRoot:“
档案:[
扩展:正确
cwd:“/scripts”
src:“***咖啡”
目标:“.tmp/脚本”
分机:“.js”
]
地区:
选项:
sourceMap:false
sourceRoot:“
档案:[
扩展:正确
cwd:“/scripts”
src:“***咖啡”
目标:“.tmp/脚本”
分机:“.js”
]
使用准备:
html:“/index.html”
选项:
目的地:“
流量:
步骤:
js:[“concat”]
css:[“concat”]
职位:[]
usemin:
html:[“/***/*.html”、“!/bower\u组件/**”]
css:[“/styles/***/.css”]
选项:
目录:[“”]
htmlmin:
地区:
选项:{}
档案:[
扩展:正确
cwd:“
src:[“*.html”,“views/*.html”]
目的地:“
]
副本:
地区:
档案:[
扩展:正确
多特:是的
cwd:“
目的地:“
src:[
“视图/***”
]
,
扩展:正确
cwd:“.tmp”
目的地:“
src:[“样式/**”,“资产/**”]
,
扩展:正确
cwd:“.tmp/图像”
目标:“/images”
src:[“已生成/*”]
]
风格:
扩展:正确
cwd:“/styles”
目的地:“.tmp/styles/”
src:“***.css”
同时发生的:
服务器:[“咖啡:服务器”、“指南针:服务器”、“副本:样式”]
地区:[“咖啡:地区”、“指南针:地区”、“复制:风格”、“htmlmin”]
康卡特:
选项:
分隔符:grunt.util.linefeed+';'+grunt.util.linefeed
地区:
src:[“/bower\u components/angular/angular.min.js”]
dest:“/scripts/vendor.js”
丑陋的:
选项:
马槽:错
地区:
文件夹:
“/scripts/app.js”:[“.tmp/***/.js”]
grunt.registerTask“服务器”(目标)->
如果目标为“dist”,则返回grunt.task.run([“build”、“open”、“connect:dist:keepalive”])