gulp服务器没有在任何端口上运行

时间:2015-10-04 19:46:25

标签: gulp

嘿伙计们我是angularJs的新手,所以我正在学习。我之前在端口8080上使用了xampp,现在当我设置gulp服务器时,它说它已成功启动但浏览器上没有任何内容。试图改变端口,但没有工作。我做错了什么?这是我的gulpfile.js

 var gulp   = require('gulp'),
    connect = require('gulp-connect'),
    historyApiFallback = require('connect-history-api-fallback');

    //Development Web Server
gulp.task('server', function(){
    connect.server({
        root: './app',
        hostname: 'localhost',
        port: 2020,
        liverload: true,
        middleware: function(connect, opt){
            return [ historyApiFallback ];
        }

    });

    });


var stylus = require('gulp-stylus'),
    nib    = require('nib');


//Preprocess Stylus files to CSS and reload changes
gulp.task('css', function(){
    gulp.src('./app/stylesheets/main.styl')
       .pipe(stylus({use: nib()}))
       .pipe(gulp.dest('./app/stylesheets'))
       .pipe(connect.reload());
});



//Reload the browser on HTML changes
gulp.task('html', function(){
    gulp.src('./app/**/*.html')
       .pipe(connect.reload());
});





//watch code changes and to run related tasks
gulp.task('watch' , function(){
    gulp.watch(['./app/**/*.html'],['html']);
    gulp.watch(['./app/stylesheets/**/*.styl'],['css']);

});

gulp.task('default', ['server', 'watch']);

0 个答案:

没有答案
相关问题