node.js - Add express to Gruntfile -
i add express routes working when run grunt server
. code written in coffee script, if don't have knowledge on coffee script answer without it, rewrite. have tried grunt-express
, grunt-express-server
, many others without success. gruntfile.
"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 "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"]
Comments
Post a Comment