2
방금 변경된 파일을 uglify하는 Gruntfile.js를 설정하려고합니다. 내가 질문에서 이것 좀 적응했고 나는이 이해 한대로Gruntfile.js는 변경된 파일 만 uglifies합니다.
에 주어진 답 이벤트는 다음이 될하기 위해 추하게 작업 src
변경되는, 시계 이벤트를 트리거해야 현재 파일 경로. 그러나 GruntJS는 방금 변경된 파일이 아니라 모든 파일을 여전히 uglify합니다.
GruntJS가 여기에서 작동하는 방식을 오해했는지 확실하지 않지만 누구나 내가 잘못 가고 있다고 제안 할 수 있습니까?
var productionPath = "production", devPath = "dev";
module.exports = function(grunt) {
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
build: {
expand: true,
cwd: devPath + '/js/',
src: ['**/*.js'],
dest: productionPath + '/js/',
ext: '.min.js'
}
},
watch: {
options: { spawn: false },
scripts: {
files: [devPath + '/**/*.js'],
tasks: ['uglify']
}
}
});
grunt.registerTask('default', ['uglify', 'watch']);
grunt.event.on('watch', function(action, filepath, target) {
grunt.config('uglify.build.src', filepath);
});
};