我找不到在 cloud9.io 中设置 gulp browsersync 的说明。我认为 browsersync 的设置 ip 和 host 是错误的。我尝试在我的 gulpfile.coffee 中这样做:
require('coffee-script/register')
gulp = require('gulp')
$ = require('gulp-load-plugins')()
browserSync = require('browser-sync')
gulp.task 'sass', ->
return gulp.src(['./sass/**/*.sass'])
.pipe($.sourcemaps.init())
.pipe($.sass({
indentedSyntax: true,
errLogToConsole: true,
outputStyle: 'compressed'
}))
# .pipe($.autoprefixer('last 3 version'))
.pipe($.sourcemaps.write('.'))
.pipe(gulp.dest('./css'))
gulp.task 'stylus', ->
gulp.src('./stylus/**/*.styl')
.pipe($.sourcemaps.init())
.pipe($.stylus())
.pipe($.sourcemaps.write('.'))
.pipe(gulp.dest('./css'))
gulp.task 'server', ->
browserSync({
server: {
baseDir: "./",
port: process.env.PORT,
host: process.env.IP
},
browser: "google chrome"
})
gulp.task 'watch', ->
gulp.watch(['./sass/**/*.sass'], ['sass'])
gulp.watch(['./stylus/**/*.styl'], ['stylus'])
gulp.task 'default', ['server', 'sass', 'stylus', 'watch']
当我运行命令'gulp'时:
suenot@car:~/workspace $ gulp
[17:20:06] Requiring external module coffee-script/register
[17:20:10] Using gulpfile ~/workspace/gulpfile.coffee
[17:20:10] Starting 'server'...
[17:20:10] 'server' errored after 249 μs
[17:20:10] ReferenceError: $PORT is not defined
at Gulp.<anonymous> (/home/ubuntu/workspace/gulpfile.coffee:29:19)
at module.exports (/home/ubuntu/workspace/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
at Gulp.Orchestrator._runTask (/home/ubuntu/workspace/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
at Gulp.Orchestrator._runStep (/home/ubuntu/workspace/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
at Gulp.Orchestrator.start (/home/ubuntu/workspace/node_modules/gulp/node_modules/orchestrator/index.js:134:8)
at /home/ubuntu/.nvm/v0.10.35/lib/node_modules/gulp/bin/gulp.js:129:20
at process._tickCallback (node.js:442:13)
at Function.Module.runMain (module.js:499:11)
at startup (node.js:119:16)
at node.js:929:3
我做错了什么?请帮助并为我糟糕的英语感到抱歉。