Pad*_*ddy 6 javascript uglifyjs gruntjs
如果我在下面发布的示例Gruntfile中的'js'目录下有多个子目录,并且想要将子目录保留在不同的目标目录下,我该怎么做?
例如
module.exports = function (grunt) {
grunt.initConfig({
// define source files and their destinations
uglify: {
files: {
src: 'js/**/*.js', // source files mask
dest: 'minJs/', // destination folder
expand: true, // allow dynamic building
flatten: true, // remove all unnecessary nesting
}
}
});
// load plugins
grunt.loadNpmTasks('grunt-contrib-uglify');
// register at least this one task
grunt.registerTask('default', [ 'uglify' ]);
};
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我已经显示了*/ .js,但即使我明确指定了一个像js/xyz/*.js这样的子目录,那么它也不是复制目录结构,而是将它们放在minJs下的子目录中/示例中的文件夹.我在这里错过了什么?请帮忙.
谢谢,
帕迪
将flatten属性设置为false.
关于grunt copy github自述文件有一个明确的解释
https://github.com/gruntjs/grunt-contrib-copy
摘抄:
$ grunt copy
Running "copy:main" (copy) task
Created 1 directories, copied 1 files
Done, without errors.
$ tree -I node_modules
.
??? Gruntfile.js
??? dest
? ??? src
? ??? a
? ??? subdir
??? src
??? a
??? subdir
??? b
5 directories, 4 files
Flattening the filepath output:
copy: {
main: {
expand: true,
cwd: 'src/',
src: '**',
dest: 'dest/',
flatten: true,
filter: 'isFile',
},
},
$ grunt copy
Running "copy:main" (copy) task
Copied 2 files
Done, without errors.
$ tree -I node_modules
.
??? Gruntfile.js
??? dest
? ??? a
? ??? b
??? src
??? a
??? subdir
??? b
3 directories, 5 files
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7258 次 |
| 最近记录: |