-
-
Save cagartner/048019e11ebd497d01c928c8ced7e92d to your computer and use it in GitHub Desktop.
Magento 2 Minification Gulp Script
This file contains hidden or 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
var gulp = require('gulp'); | |
var cleanCSS = require('gulp-clean-css'); | |
var minify = require('gulp-minify'); | |
gulp.task('default', [ | |
'css', | |
'requireJsMinify', | |
'jsMinify' | |
]); | |
gulp.task('css', function() { | |
return gulp.src('./../pub/static/frontend/YourTheme/default/en_GB/**/*.css') | |
.pipe(cleanCSS({compatibility: 'ie9', processImport: false})) | |
.pipe(gulp.dest('./../pub/static/frontend/YourTheme/default/en_GB/')); | |
}); | |
gulp.task('requireJsMinify', function() { | |
gulp.src('./../pub/static/_requirejs/frontend/YourTheme/default/en_GB/**/*.js') | |
.pipe(minify({ | |
ext: { | |
min: '.js' | |
}, | |
noSource: {} | |
})) | |
.pipe(gulp.dest('./../pub/static/_requirejs/frontend/YourTheme/default/en_GB/')); | |
}); | |
gulp.task('jsMinify', function() { | |
gulp.src('./../pub/static/frontend/YourTheme/default/en_GB/**/*.js') | |
.pipe(minify({ | |
ext: { | |
min: '.js' | |
}, | |
mangle: false, | |
noSource: {} | |
})) | |
.pipe(gulp.dest('./../pub/static/frontend/YouTheme/default/en_GB/')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment