【发布时间】:2014-08-24 07:35:26
【问题描述】:
我正在设置一个 Gruntfile,我正在尝试:
- 将一些咖啡脚本编译为客户端的javascript。
- 注意要编译为客户端 javascript 的咖啡脚本的更改。
- 注意后端(服务器)coffeescript 文件的更改,并在发现更改时重新启动咖啡应用程序。
我已经完成了前两个步骤:
module.exports = (grunt) ->
grunt.initConfig
pkg: grunt.file.readJSON 'package.json'
coffee:
compile:
expand: true
flatten: true
cwd: 'public/src'
src: ['*.coffee']
dest: 'public/dist'
ext: '.js'
watch:
coffee:
files: ['public/src/*.coffee']
tasks: ['coffee']
grunt.loadNpmTasks 'grunt-contrib-coffee'
grunt.loadNpmTasks 'grunt-contrib-watch'
grunt.registerTask 'default', ['coffee', 'watch']
但我不知道如何进行第三步。
目前目录结构如下:
app
lib.coffee
routes.coffee
public/
dist/
client.js
src/
client.coffee
Gruntfile.coffee
package.json
server.coffee
我如何观察 app 目录或 server.coffee 文件中的任何内容的更改并使用 grunt 自动启动服务器(例如“coffee server.coffee”)?
服务器也使用 express - 重新启动应用程序是否需要在启动之前查看端口是否再次可用?
【问题讨论】:
标签: coffeescript gruntjs grunt-contrib-watch grunt-contrib-coffee