Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <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>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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