gulp.src('client/templates/*.jade')
.pipe(jade())
.pipe(minify())
.pipe(gulp.dest('build/minified_templates'));
gulp.src('./client/templates/*.jade')
.pipe(jade())
.pipe(gulp.dest('./build/templates'))
.pipe(minify())
.pipe(gulp.dest('./build/minified_templates'));
gulp.task('somename', function() {
// Do stuff
});
gulp.task('somename', function() {
var stream = gulp.src('client/**/*.js')
.pipe(minify())
.pipe(gulp.dest('build'));
return stream;
});
var watcher = gulp.watch('js/**/*.js',
['uglify','reload']);
watcher.on('change', function(event) {
// Do some staff
});
// Минивебсервер для livereload
var lr = require('tiny-lr'),
// Сообственно Gulp JS
gulp = require('gulp'),
// Плагин для Stylus
stylus = require('gulp-stylus'),
// Livereload для Gulp
livereload = require('gulp-livereload'),
// Плагин для Myth
myth = require('gulp-myth'),
// Минификация CSS
csso = require('gulp-csso'),
// Собираем Stylus
gulp.task('stylus', function() {
gulp.src('./assets/stylus/screen.styl')
.pipe(stylus({
use: ['nib']
})) // собираем stylus
// Если есть ошибки, выводим и продолжаем
.on('error', console.log)
// добавляем префиксы
.pipe(myth())
// записываем css
.pipe(gulp.dest('./public/css/'))
// даем команду на перезагрузку css
.pipe(livereload(server));
});
$ gulp stylus
var through = require('through2');
var path = require('path');
module.exports = function(ext, replaceExt) {
var extension_replace = function(file, encoding, callback){
var replaceExt = replaceExt || false,
_path = file.path;
if (typeof ext === 'string' && ext.length > 0) {
ext = ext.indexOf('.') === 0 ? ext : '.' + ext;
file.path = _path.replace(
replaceExt ?
replaceExt :
path.extname(_path),
ext
);
}
callback(null, file);
};
return through.obj(extension_replace);
};
var ext_replace = require('./ext-replace');
gulp.task('change', function() {
gulp.src('styles/*.css')
.pipe(ext_replace('.scss'))
.pipe(gulp.dest('dist'))
});
var fs = require('vinyl-fs'),
gzip = require('gulp-gzip')
grunt.registerTask('zip', function () {
fs.src('./build/build.js')
.pipe(gzip())
.pipe(fs.dest('./build'))
.on('end', this.async())
})
var gulp = require('gulp');
require('gulp-grunt')(gulp);
//task definition
gulp.task('default', function(){
//run complete grunt tasks
gulp.run('grunt-minify');
gulp.run('grunt-test-assets')
//or run specific targets
gulp.run('grunt-sass:dist');
gulp.run('grunt-browserify:dev');
});
var gulp = require("gulp");
var webpack = require("webpack");
var WebpackDevServer =
require("webpack-dev-server");
gulp.task("webpack", function(callback) {
// run webpack
webpack({
// configuration
}, function(err, stats) {
//error handling
callback();
});
});
gulp.task("webpack-dev-server",
function(callback) {
// Start a webpack-dev-server
var compiler = webpack({
// configuration
});
new WebpackDevServer(compiler, {
// server and middleware options
}).listen(8080, "localhost",
function(err){
// Server listening
// Errors handling
callback();
}
);
});