无法使用browsersync获取GET错误

时间:2017-09-24 10:35:06

标签: npm gulp

我是gulp和node.js的新手。因此,我正在尝试将Pug,sass和browsersync打包到gulpfile.js中。 Pug和scss成功编译成功但当我尝试使用browsersync在localhost上查看结果时,会弹出Can not GET错误。注意:对图片链接感到抱歉,我的代表不到10个。

gulpfile.js

var gulp = require('gulp');
var jade = require('gulp-jade');
var sass = require('gulp-sass');
var browserSync = require('browser-sync');


gulp.task('browserSync', function () {
    browserSync.init({
        server:{
            baseDir:'CSS Grid'
        }
    });
});

gulp.task('jade', function(){
    return gulp
        .src('./pug/*.jade')
        .pipe(jade({
            pretty: true
        }))
        .pipe(gulp.dest('./html'))
});

gulp.task('scss', function(){
    return gulp
        .src("./sass/*.scss")
        .pipe(sass())
    .pipe(gulp.dest("./css"))
});

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


gulp.task('watch',['browserSync'], function(){
    gulp.watch('./html/*.html', browserSync.reload);
    gulp.watch('./css/*.css', browserSync.reload);
    gulp.watch('./sass/*.scss', ['scss']);
    gulp.watch('./pug/*.jade', ['jade']);
});

package.json文件

{
  "name": "cssgrid",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "browser-sync": "^2.18.13",
    "gulp": "^3.9.1",
    "gulp-jade": "^1.1.0",
    "gulp-sass": "^3.1.0",
    "gulp-scss": "^1.4.0"
  }
}

Folder Directory Structure

0 个答案:

没有答案