Skip to content

Instantly share code, notes, and snippets.

@meseven
Created February 28, 2018 13:23
Show Gist options
  • Save meseven/dbda3aeaa267b9edf5094f2f0b6e5a58 to your computer and use it in GitHub Desktop.
Save meseven/dbda3aeaa267b9edf5094f2f0b6e5a58 to your computer and use it in GitHub Desktop.
Gulp
const gulp = require('gulp');
const minify = require('gulp-minify');
const minifyCSS = require('gulp-minify-css');
const rename = require('gulp-rename');
const concat = require('gulp-concat');
gulp.task('styles', () => {
gulp.src('source/css/**/*.css')
.pipe(minifyCSS())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('dist/css'))
});
gulp.task('scripts', () => {
gulp.src(['source/js/**/*.js'])
.pipe(concat('all.js'))
.pipe(minify({
ext: {
min: '.min.js'
},
noSource: true
}))
.pipe(gulp.dest('dist/js'))
});
gulp.task('watch', () => {
gulp.watch('source/css/**/*.css', ['styles']);
gulp.watch('source/js/**/*.js', ['scripts']);
});
gulp.task('default', ['styles', 'scripts', 'watch']);
{
"name": "project",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"gulp": "^3.9.1",
"gulp-concat": "^2.6.1",
"gulp-minify": "^2.1.0",
"gulp-minify-css": "^1.2.4",
"gulp-rename": "^1.2.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment