javascript Magento 2 Minification Gulp Script

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript 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/'));
});

以上是关于javascript Magento 2 Minification Gulp Script的主要内容,如果未能解决你的问题,请参考以下文章

javascript Magento 2 Minification Gulp Script

Magento :: 从 javascript 文件中翻译文本

Magento Javascript弹出窗口

JavaScript 光(4kb mini-jQuery)

JavaScript mini-pico-tiny ajax

在 Opera mini 中调试 javascript