Minify CSS to simplify

0

I try to minify my css code to improve the loading of my website. I have tried for css clean and minify css, but the code that returns is always commented. Any help?

    
asked by PiledroMurcia 19.09.2017 в 16:44
source

1 answer

1

Have you tried using Gulp ? Gulp itself is a task automator, but supported by the css and js minification packages you can quickly minify all the content. In addition to seeing many other functions for which I could help you.

var gulp = require('gulp');
var browserify = require('gulp-browserify');
var uglify = require('gulp-uglify');
var cssmin = require('gulp-cssmin');
var rename = require('gulp-rename');
var htmlmin = require('gulp-htmlmin');

gulp.task('minifycss', function() {

  archivosCss=gulp.src('ruta/tus/css');

  return  archivosCss    
          .pipe(cssmin())
          .pipe(rename({suffix:'.min'}))
          .pipe(gulp.dest('app/css/'));

});

gulp.task('minifyjs', function(){
  gulp.src('ruta/tus/js')
    .pipe(concat('script.js'))
    .pipe(browserify())
    .pipe(uglify())
    .pipe(gulp.dest('app/js'))
});

gulp.task('minifyHTML', function(){
  return gulp.src('./*.html')
              .pipe(htmlmin({collapseWhitespace:true}))
              .pipe(gulp.dest('app'));
});

gulp.task('all', ['minifycss','minifyjs','minifyHTML']);

gulp.task('default',['all']);

In this example, you minify, your css, your js and even your html, making it much lighter.

If you opt for this option, and have any questions during the process, do not hesitate to let me know and I will complete it with the information you need.

    
answered by 19.09.2017 / 17:22
source