Created
June 5, 2017 02:13
-
-
Save Mark24Code/a50742864e518b057a994cf509998f7b to your computer and use it in GitHub Desktop.
微信小程序Gulp & Sass
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@charset "UTF-8"; | |
@function rpx($v) { | |
@return $v/1px * 1rpx; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************* | |
* gulp 依赖 | |
*******************/ | |
var | |
gulp = require('gulp'), | |
fs = require('fs'), //node 文件系统 | |
path = require('path'), //node 路径处理 | |
rename = require('gulp-rename'), //改名 | |
changed = require('gulp-changed'), //只修改修改过的文件 | |
sass = require('gulp-sass')//scss预处理 | |
; | |
/******************* | |
* 全局配置 | |
*******************/ | |
var config = { | |
src: './pages' | |
}; | |
/******************* | |
* 任务 | |
*******************/ | |
// sass 处理 | |
gulp.task('scss', function () { | |
return gulp.src(config.src + '/**/*.scss') | |
.pipe(sass().on('error', sass.logError)) | |
.pipe(rename(function(path){ | |
path.extname = '.wxss'; | |
})) | |
.pipe(gulp.dest(config.src)) | |
.on('end', function() { | |
console.log('[完成] sass 编译完毕'); | |
}); | |
}); | |
//监视 | |
gulp.task('watch', function(event) { | |
gulp.watch(config.src+ '/**/*.scss', ['scss']); | |
}); | |
//开发 | |
gulp.task('dev', ['watch', 'scss']); | |
//帮助 | |
gulp.task('help', function() { | |
console.log('----------- gulp命令 -----------'); | |
console.log('gulp 命令清单'); | |
console.log('----------- 开发环境 -----------'); | |
console.log('gulp dev 开发模式'); | |
}); | |
//默认任务 | |
gulp.task('default', ['help']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment