Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>My solution:</p> <pre><code>grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), cssmin: { dist: { expand: true, cwd: 'app', src: ['**/*.css'], dest: 'WebContent' } }, uglify: { options: { mangle: false }, dist: { expand: true, cwd: 'app/js', src: ['**/*.js'], dest: 'WebContent/js' } }, htmlmin: { options: { collapseWhitespace: true }, dist: { expand: true, cwd: 'app', src: ['**/*.html'], dest: 'WebContent' } }, watch: { options: { spawn: false }, cssmin: { files: 'app/css/**/*.css', tasks: ['cssmin'] }, uglify: { files: 'app/js/**/*.js', tasks: ['uglify'] }, htmlmin: { files: 'app/**/*.html', tasks: ['htmlmin'] } }, }); // Faz com que seja salvo somente o arquivo que foi alterado grunt.event.on('watch', function(action, filepath) { var tasks = ['cssmin', 'uglify', 'htmlmin']; for (var i=0, len=tasks.length; i &lt; tasks.length; i++) { var taskName = tasks[i]; if (grunt.file.isMatch(grunt.config('watch.'+ taskName +'.files'), filepath)) { var cwd = new String(grunt.config(taskName + '.dist.cwd')).split('/').join('\\') + '\\'; //inverte as barras e adiciona uma "\" no final var pathWithoutCwd = filepath.replace(cwd, ''); //obtem somente o path sem o cwd grunt.config(taskName + '.dist.src', pathWithoutCwd); //configura a task } } }); grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-contrib-cssmin'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-htmlmin'); // Tarefas padrão grunt.registerTask('default', ['cssmin', 'uglify', 'htmlmin']); }; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload