-
-
Save ut4utc/cb8b218a9c2e097ef72fec4368919597 to your computer and use it in GitHub Desktop.
Magento 2 Minification Gulp Script
This file contains 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