3 Star 0 Fork 0

cloudfroster/waibao

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
gulpfile.js 1.96 KB
一键复制 编辑 原始数据 按行查看 历史
cloudfroster 提交于 2016-06-30 23:03 . 4个页面进组
'use strict'
const gulp = require('gulp')
const less = require('gulp-less')
const jade = require('gulp-jade')
const watch = require('gulp-watch')
const plumber = require('gulp-plumber')
const autoprefixer = require('autoprefixer')
const postcss = require('gulp-postcss')
const sourcemaps = require('gulp-sourcemaps')
const bs = require('browser-sync').create()
// 配置路径
const direction = {
jade: {
src: ['./views/**/*.jade', '!./views/common/**/*.jade'],
dest: './views',
},
less: {
src: ['./public/**/*.less'],
dest: './public',
},
}
gulp.task('jade', () => {
return watch(direction.jade.src, { ignoreInitial: false })
.pipe(sourcemaps.init())
.pipe(plumber())
.pipe(jade({ pretty: true })).on('error', (error) => { console.log(error.message) })
.pipe(sourcemaps.write('./sourcemaps'))
.pipe(gulp.dest(direction.jade.dest))
})
gulp.task('less', () => {
return watch(direction.less.src, { ignoreInitial: false })
.pipe(sourcemaps.init())
.pipe(plumber())
.pipe(less({ compress: false })).on('error', (error) => { console.log(error.message) })
.pipe(postcss([autoprefixer({
browsers: [
'Android >= 4',
'Chrome >= 35',
'Firefox >= 31',
'Explorer >= 9',
'iOS >= 7',
'Opera >= 12',
'Safari >= 7.1',
'IE >= 8',
]
})]))
.pipe(sourcemaps.write('./sourcemaps'))
.pipe(gulp.dest(direction.less.dest))
})
gulp.task('bs-server', () => {
bs.init({
server: {
baseDir: direction.jade.dest,
directory: true
},
port: 3001,
files: [direction.less.dest + '/**/*.css'],
})
})
gulp.task('bs-proxy', () => {
bs.init({
proxy: 'localhost',
port: 3001,
files: [direction.less.dest + '/**/*.css'],
})
})
gulp.task('default', ['jade', 'less', 'bs-server'])
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/marchen/waibao.git
git@gitee.com:marchen/waibao.git
marchen
waibao
waibao
master

搜索帮助