【发布时间】:2016-09-02 08:21:18
【问题描述】:
我正在使用Grunt 对我的项目中的 javascipt 文件进行 uglify。
问题:
如何对子文件夹/子目录中的所有javascript文件进行uglify?
我在 Gruntfile.js 中做了什么:
目前它只会对 js 文件夹中的那些 javascript 文件进行 uglify,因为我使用的是 src: 'js/*.js'。但是我在 js 文件夹中有其他目录,其中包含 javascript 文件:
├── 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' ]);
};
【问题讨论】:
-
@mplungjan thx!
标签: javascript gruntjs uglifyjs