Gulp Minification

1

Does anyone know how to minify js and css files at run time. For example: In the Html file, the call to the Javascript file looks like this:

<script src="~/Content/Site/js/funcoes.js"></script>

I would like a mined script file to be generated at the time of application execution, would this be possible?

    
asked by anonymous 16.12.2016 / 19:09

1 answer

1

That way you'll be able to teach javascript and css

var htmlReplace = require('gulp-html-replace') // troca os textos dentro do html
,uglify = require('gulp-uglify') // ninifica js
,usemin = require('gulp-usemin')              /
,cssmin = require('gulp-cssmin') // minifica o tamanho do css

gulp.task('usemin', function() {
  return gulp.src('dist/**/*.html')
    .pipe(usemin({
      js: [uglify],
      css: [cssmin]
    }))
    .pipe(gulp.dest('dist'));
});

In index.html you should comment to show the gulp htmlReplace where the files that are to be mined are

example:

    
13.03.2017 / 04:00