亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

javascript - gulp serve 啟動(dòng),打不開(kāi)頁(yè)面載入出錯(cuò)?想實(shí)作gulp watch自動(dòng)刷新 。
過(guò)去多啦不再A夢(mèng)
過(guò)去多啦不再A夢(mèng) 2017-05-19 10:18:48
0
1
671

gulpfile.js的程式碼如下


var gulp = require('gulp');
var $ = require('gulp-load-plugins')();//這樣就可以直接引用$變量,不需要聲明
var open = require('open');
// const gulp = require('gulp');
// const imagemin = require('gulp-imagemin');

var app = {
    srcPath:'src/',
    devPath:'build/',
    prdPath:'dist/'
};

//放置依賴(lài)
gulp.task('lib',function () {
    gulp.src('bower_components/**/*.js')
        .pipe(gulp.dest(app.devPath + 'vendor'))
        .pipe(gulp.dest(app.prdPath + 'vendor'))
        .pipe($.connect.reload());
});

gulp.task('html',function () {
gulp.src(app.srcPath + '**/*.html')
    .pipe(gulp.dest(app.devPath))
    .pipe(gulp.dest(app.prdPath))
    .pipe($.connect.reload());
});

gulp.task('json',function () {
    gulp.src(app.srcPath + 'data/**/*.json')
        .pipe(gulp.dest(app.devPath + 'data'))
        .pipe(gulp.dest(app.prdPath + 'data'))
        .pipe($.connect.reload());
});

gulp.task('less',function () {
    gulp.src(app.srcPath + 'style/index.less')
        .pipe($.less())
        .pipe(gulp.dest(app.devPath + 'css'))
        .pipe($.cssmin())//壓縮
        .pipe(gulp.dest(app.prdPath + 'css'))
        .pipe($.connect.reload());
});

gulp.task('js',function () {
    gulp.src(app.srcPath + 'script/**/*.js')
        .pipe($.concat('index.js'))
        .pipe(gulp.dest(app.devPath + 'js'))
        .pipe($.uglify())
        .pipe(gulp.dest(app.prdPath + 'js'))
        .pipe($.connect.reload());
});

gulp.task('image',function () {
    gulp.src(app.srcPath + 'image/**/*')
        .pipe(gulp.dest(app.devPath + 'image'))
        .pipe($.imagemin())
        .pipe(gulp.dest(app.prdPath + 'image'))
        .pipe($.connect.reload());
});

gulp.task('build',['image','js','less','json','html','lib']);

// gulp.task('clean',function () {
//     gulp.src([app.devPath,app.prdPath])
//         .pipe($.clean());
// });

gulp.task('serve',['build'],function () {
    $.connect.server({
        root:'./',
        livereload:true,
        port:3000
    });
    open('http://localhost:3000');
});

gulp.task('watch',function () {
    gulp.watch('bower_components/**/*',['lib']);
    gulp.watch(app.srcPath + '**/*.html',['html']);
    gulp.watch(app.srcPath + 'data/**/*.json',['json']);
    gulp.watch(app.srcPath + 'style/**/*.less',['less']);
    gulp.watch(app.srcPath + 'script/**/*.js',['js']);
    gulp.watch(app.srcPath + 'image/**/*',['image']);
});


gulp.task('default',['watch','serve']);//默認(rèn)任務(wù)

是我serve設(shè)定有問(wèn)題嗎?
使用的是火狐瀏覽器。 。應(yīng)該是最新版。 。求助
還有之前的問(wèn)題也沒(méi)解決,那個(gè)imagemin壓縮不了圖片,我寫(xiě)在另一個(gè)問(wèn)題裡面了

試著把serve的root改成[app.srcPath],能打開(kāi)index頁(yè)面了,但不能自動(dòng)刷新

還有一個(gè)報(bào)錯(cuò)。 。 。 。伺服器打開(kāi)的連接埠也不對(duì)。 。

#
過(guò)去多啦不再A夢(mèng)
過(guò)去多啦不再A夢(mèng)

全部回覆(1)
迷茫

html頁(yè)面程式碼中有被body標(biāo)籤包裹嗎

最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板