Skip to content

Instantly share code, notes, and snippets.

@lewisp6
Created September 2, 2016 10:59
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save lewisp6/b7c50b4d82ef4d3d5d6dc888e8d1bdba to your computer and use it in GitHub Desktop.
Save lewisp6/b7c50b4d82ef4d3d5d6dc888e8d1bdba to your computer and use it in GitHub Desktop.
Magento 2 Minification Gulp Script
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/'));
});
@zchking
Copy link

zchking commented Dec 9, 2016

thank you , how to config magento2 let it read this min js file?

@robertbaum
Copy link

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