我正在使用Grunt来丑化我的项目中的javascipt文件。如何uglify使用Grunt的子文件夹/子目录中的所有javascript文件?
问:
如何丑化子文件夹/子目录中的所有JavaScript文件?
我在Gruntfile.js做什么:
目前,它只会丑化那些因为我使用的src中的js文件夹中的JavaScript文件: 'JS/* JS'。不过,我有在具有JavaScript文件夹的js其他目录:
├── CommonUtil.js
├── Paging
│ ├── dirPagination.js
│ └── dirPagination.tpl.html
├── angular-chart.js
├── angular-elastic-input.min.js
├── angularAlt.js
├── authenticationChallengeHandler
│ └── loginChallengeHandler.js
Gruntfile.js
module.exports = function (grunt) {
grunt.initConfig({
// define source files and their destinations
uglify: {
files: {
src: 'js/*.js', // source files mask
dest: 'jsm/', // destination folder
expand: true, // allow dynamic building
flatten: true, // remove all unnecessary nesting
ext: '.min.js' // replace .js to .min.js
}
},
watch: {
js: { files: 'js/*.js', tasks: [ 'uglify' ] },
}
});
// load plugins
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-uglify');
// register at least this one task
grunt.registerTask('default', [ 'uglify' ]);
};
或许这将告诉您如何? http://stackoverflow.com/questions/19138329/grunt-recursive-copy – mplungjan
@mplungjan thx! – user1872384