Chris Yip
Front-end Leader @ feifei.com
npm install -g grunt grunt-cli grunt-init git clone https://github.com/gruntjs/grunt-init-gruntfile.git ~/.grunt-init/gruntfile mkdir PROJECT_NAME && cd $_
grunt-init gruntfile
# answer a few questions
npm install
grunt # start the default task
npm install --save-dev load-grunt-tasks grunt-contrib-less
module.exports = function (grunt) {
require('load-grunt-tasks')(grunt)
grunt.initConfig({
yeoman: { src: 'src/', dist: 'dist/' },
less: {
main: {
expand: true,
cwd: '<%= yeoman.src %>',
src: ['*.less'],
dest: '<%= yeoman.dist %>',
ext: '.css'
}
}
})
grunt.registerTask('default', ['less'])
}
npm install -g gulp
npm init
npm install --save-dev gulp
mkdir PROJECT_NAME && cd $_
touch gulpfile.js
npm install --save-dev gulp-less
const gulp = require('gulp'),
less = require('gulp-less')
gulp.task('less', function () {
return gulp
.src('/less/*.less')
.pipe(less({ compress: true }))
.pipe(gulp.dest('/css'))
})
gulp less
via http://labs.tmw.co.uk/2014/01/speedtesting-gulp-and-grunt/
gulp.task('build', ['js', 'less', 'jade'])
gulp.task('deploy', ['build'], function (cb) {
var build = require('./build')
, deploy = require('./deploy')
, tar = require('gulp-tar')
, gzip = require('gulp-gzip')
build(ENV).then(function () {
gulp
.src('.build')
.pipe(tar('build.tar'))
.pipe(gzip())
.pipe(deploy())
cb()
})
})
const jshint = require('gulp-jshint'),
, stylish = require('jshint-stylish')
gulp.task('jshint', function () {
return gulp
.src('**/*.js')
.pipe(jshint())
.pipe(jshint.reporter(stylish))
})
gulp.src(['**/*.js', '!node_modules{,/**}'])
const uglify = require('gulp-uglifyjs')
gulp.task('js', function () {
return gulp
.src('**/*.js')
.pipe(uglify({ outSourceMap: true }))
.pipe(gulp.dest('dist/'))
})
const livereload = require('gulp-livereload')
gulp.task('watch', function () {
livereload.listen()
gulp
.watch('**/*.{js,css,png,jpg,gif,jpeg,webp}')
.on('change', livereload.changed)
gulp.watch(['**/*.js'], function (event) {
gulp
.src(event.path)
.pipe(jshint())
.pipe(jshint.reporter(stylish))
})
})