gulpfile.js

Posted 码农io

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了gulpfile.js相关的知识,希望对你有一定的参考价值。

var gulp = require("gulp");

var sass = require("gulp-sass");

var sourcemaps = require("gulp-sourcemaps");

var connect = require("gulp-connect");

var concat = require("gulp-concat");

var uglify = require("gulp-uglify");

var rename = require("gulp-rename");

var babel = require("gulp-babel");

gulp.task ("img",function(){

gulp.src(["img/**"])

.pipe(gulp.dest("dist/img"))

})

gulp.task ("html",function(){

gulp.src("*.html")

.pipe(gulp.dest("dist"))

.pipe(connect.reload());

})

gulp.task ("data",function(){

gulp.src(["*.js","!gulpfile.js",])

.pipe(gulp.dest("dist"))

})

gulp.task("watch",function(){

gulp.watch(["*.html","*.js","!gulpfile.js","*.css","img/**"],["data","img","html","sass"])

})

gulp.task("sass",function(){

gulp.src("main.scss")

.pipe(sourcemaps.init())

.pipe(sass({outputStyle: 'compressed'}))

.pipe(sourcemaps.write())

.pipe(gulp.dest("dist/css"))

})

gulp.task("server",function(){

connect.server({

"root":"dist",

"livereload":true

})

});


gulp.task("default",["server","watch"])


以上是关于gulpfile.js的主要内容,如果未能解决你的问题,请参考以下文章