Created
September 2, 2016 10:59
-
-
Save lewisp6/b7c50b4d82ef4d3d5d6dc888e8d1bdba 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/')); | |
}); |
How to implement this
where must placed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you , how to config magento2 let it read this min js file?