简体   繁体   中英

How to use gulp.js to minimize wordpress css and javascript

I have a very simple question. I started using gulp.js to reduce css / javascript files. Now I wondered if it was possible to minimize all files (css and javascript). The intention is that the css and javascript files are simply overwritten and not put in a separate folder if they are minimized :)

You would need to configure gulp's target to be same as the source.

But in general it's good practice to have separate files.

Example:

var gulp = require('gulp') , 
   minifyCss = require("gulp-minify-css"); 
// task 
gulp.task('minify-css', function () { 
  gulp.src(['css/main.css','css/second.css',]) 
  .pipe(minifyCss()) 
  .pipe(gulp.dest('css/minified/'));
 });

Me personally i just use a caching plugin for Wordpress which does aggregation and minification of JS files. There are plenty.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM