新しくExpressの環境を作り、以前作成したプロジェクトの
gulpfile.jsをコピーして
・サーバーのホストとポート
・ライブリロードのポート
を書き換えました。hostsにも追加済みです。
※以前作成したプロジェクトでは動作します。
タスクを単体で動作させるとどれも動作するのですが、
「webserver」のタスクを動作させると「livereload[tiny-lr] listening on 35729 ...」まで行った後、
処理が終了します。
また、「npm start」コマンドでは起動します。
何かわかる方はいらっしゃいますでしょうか・・・。
var gulp = require('gulp'), webserver = require('gulp-webserver'), jade = require('gulp-jade'), plumber = require('gulp-plumber'), sass = require('gulp-sass'), express = require('gulp-express'); //Webサーバー gulp.task('webserver', function() { gulp.src('./webroot') //Webサーバーで表示するサイトのルートディレクトリを指定 .pipe(webserver({ host: process.env.DEV_HOST || 'admin.localhost', port: process.env.DEV_PORT || 80, livereload: { enable: true, port: 35729 } //ライブリロードを有効に })); express.run({ file: './app.js' }); }); gulp.task('jade-compile', function() { gulp.src(['./views/*.jade','./public/javascripts/*.jade']) .pipe(plumber()) .pipe(jade({pretty:true})) .pipe(gulp.dest('./webroot/js/')) }); gulp.task('sass-compile', function() { gulp.src('./public/stylesheets/*.sass') .pipe(plumber()) .pipe(jade({pretty:true})) .pipe(gulp.dest('./webroot/css/')) }); gulp.task('compile', ['jade-compile', 'sass-compile']); gulp.task('watch', function(){ gulp.watch(['./views/*.jade', './public/javascripts/*.jade'], ['jade-compile']); gulp.watch(['./routes/*.js']); gulp.watch(['./public/stylesheets/*.sass'], ['sass-compile']); }); gulp.task('serve', ['compile', 'webserver', 'watch']); gulp.task('default', ['webserver','watch']);
シェルのログ
shell
1$ gulp webserver 2[17:55:38] Using gulpfile C:\Project\public_html\hoge\contact\gulpfile.js 3[17:55:38] Starting 'webserver'... 4[17:55:38] Webserver started at http://admin.localhost:80 5[17:55:38] Finished 'webserver' after 12 ms 6livereload[tiny-lr] listening on 35729 ...
あなたの回答
tips
プレビュー