parent
9184d979e2
commit
6d8c81bff0
2 changed files with 114 additions and 0 deletions
@ -0,0 +1,74 @@ |
||||
'use strict'; |
||||
|
||||
var autoprefixer = require('gulp-autoprefixer'), |
||||
path = require('path'), |
||||
minify = require('gulp-minify'), |
||||
cleanCss = require('gulp-clean-css'), |
||||
debug = require('gulp-debug'), |
||||
csso = require('gulp-csso'), |
||||
concatCss = require('gulp-concat-css'), |
||||
concatJs = require('gulp-concat'), |
||||
sourcemaps = require('gulp-sourcemaps'), |
||||
jshint = require('gulp-jshint'), |
||||
del = require('del'), |
||||
gulp = require('gulp'), |
||||
uglify = require('gulp-uglify'); |
||||
|
||||
const AUTOPREFIXER_BROWSERS = [ |
||||
'ie >= 10', |
||||
'ie_mob >= 10', |
||||
'ff >= 30', |
||||
'chrome >= 34', |
||||
'safari >= 7', |
||||
'opera >= 23', |
||||
'ios >= 7', |
||||
'android >= 4.4', |
||||
'bb >= 10' |
||||
]; |
||||
var basePath = path.dirname(__filename); |
||||
var staticPath = basePath + '/static/'; |
||||
|
||||
gulp.task('clean', gulp.series(function () { |
||||
return del([ |
||||
staticPath + 'css/build.css', |
||||
staticPath + 'js/build.js', |
||||
staticPath + 'js/build-min.js' |
||||
]); |
||||
})); |
||||
|
||||
gulp.task('minstyles', gulp.series(function () { |
||||
return del([staticPath + 'css/build.css']) |
||||
}, function () { |
||||
return gulp.src(['static/css/**/*.css'], {base: basePath}) |
||||
.pipe(autoprefixer({browsers: AUTOPREFIXER_BROWSERS})) |
||||
.pipe(concatCss('build.css')) |
||||
.pipe(sourcemaps.init()) |
||||
.pipe(cleanCss()) |
||||
.pipe(csso()) |
||||
.pipe(sourcemaps.write()) |
||||
.pipe(gulp.dest('static/css/', {base: basePath})); |
||||
})); |
||||
|
||||
gulp.task('minscripts', gulp.series(gulp.series(function () { |
||||
return del([staticPath + 'js/build.js']) |
||||
}, function () { |
||||
return gulp.src([ |
||||
'node_modules/jquery/dist/jquery.js', |
||||
'node_modules/jquery-ui-dist/jquery-ui.js', |
||||
'node_modules/magnific-popup/dist/jquery.magnific-popup.js', |
||||
'node_modules/jquery-bar-rating/dist/jquery.barrating.min.js', |
||||
'node_modules/bootstrap/dist/js/bootstrap.js', |
||||
'node_modules/jquery-autocomplete/jquery.autocomplete.js', |
||||
'static/js/**/*.js' |
||||
], {base: basePath}) |
||||
.pipe(jshint()) |
||||
.pipe(jshint.reporter('default')) |
||||
.pipe(uglify()) |
||||
.pipe(sourcemaps.init()) |
||||
.pipe(concatJs('build.js')) |
||||
.pipe(sourcemaps.write()) |
||||
.pipe(minify()) |
||||
.pipe(gulp.dest('static/js/', {base: basePath})); |
||||
}))); |
||||
|
||||
gulp.task('default', gulp.series('minstyles', 'minscripts')); |
||||
@ -0,0 +1,40 @@ |
||||
{ |
||||
"name": "local-minifier", |
||||
"version": "0.1.0", |
||||
"description": "A local environment to minify CSS, JS", |
||||
"license": "Apache-2.0", |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/amardeeprai/local-minifier" |
||||
}, |
||||
"devDependencies": { |
||||
"del": "^2.0.2", |
||||
"gulp": "^4.0.0", |
||||
"gulp-autoprefixer": "latest", |
||||
"gulp-clean-css": "^3.10.0", |
||||
"gulp-csso": "^3.0.1", |
||||
"gulp-concat": "^2.6.1", |
||||
"gulp-concat-css": "^3.1.0", |
||||
"gulp-debug": "^4.0.0", |
||||
"gulp-jshint": "^2.1.0", |
||||
"gulp-minify": "^3.1.0", |
||||
"gulp-rename": "^1.4.0", |
||||
"gulp-sourcemaps": "^2.6.4", |
||||
"gulp-uglify": "^2.0.0", |
||||
"jshint": "^2.9.6", |
||||
"minimatch": "3.0.2", |
||||
"run-sequence": "^1.2.2" |
||||
}, |
||||
"engines": { |
||||
"node": ">=0.12.0" |
||||
}, |
||||
"dependencies": { |
||||
"bootstrap": "3.3.7", |
||||
"gulp-minify-css": "^1.2.4", |
||||
"jquery": "^3.3.1", |
||||
"jquery-autocomplete": "^1.2.8", |
||||
"jquery-bar-rating": "^1.2.2", |
||||
"jquery-ui-dist": "1.12.1", |
||||
"magnific-popup": "^1.1.0" |
||||
} |
||||
} |
||||
Loading…
Reference in new issue