Node.js GruntJS+;contrib coffee:编译但保留文件夹结构
我正在使用。它工作得很好!在插件的帮助下,它甚至更好。但我的疑问来了: 我有两个文件夹,一个是我的coffeescript文件,另一个是我的(编译的)js文件。看起来像这样Node.js GruntJS+;contrib coffee:编译但保留文件夹结构,node.js,coffeescript,gruntjs,grunt-contrib-watch,Node.js,Coffeescript,Gruntjs,Grunt Contrib Watch,我正在使用。它工作得很好!在插件的帮助下,它甚至更好。但我的疑问来了: 我有两个文件夹,一个是我的coffeescript文件,另一个是我的(编译的)js文件。看起来像这样 root_folder |--- public |--- libs |--- ppalmeida <= here are my .js compiled files from src_client coffeescripts |--- controllers
root_folder
|--- public
|--- libs
|--- ppalmeida <= here are my .js compiled files from src_client coffeescripts
|--- controllers
|--- core
|--- Main.js
|--- models
|--- src_client <= here are my .coffee files
|--- controllers
|--- core
|--- Main.coffee
|--- models
所以,最后我得到了这样的结果:
root_folder
|--- public
|--- libs
|--- ppalmeida <= here are my .js compiled files from src_client coffeescripts
|--- controllers (empty)
|--- core (empty)
|--- models (empty)
|--- Main.js
|--- ControllerA.js
|--- ControllerB.js
|--- ModelA.js
|--- all_other_js_files_here.js
|--- src_client <= here are my .coffee files
|--- controllers
|--- ControllerA.coffee
|--- ControllerB.coffee
|--- core
|--- Main.coffee
|--- models
|--- ModelA.coffee
|--- ModelA.coffee
哦,现在我明白了。答案就在我面前:只需将“flatte”属性更改为“false”,这样它将保留文件的路径,这样coffeescript将使用它进行编译,并保留文件夹结构:
# Create the 'coffee' task, to compile all *.coffee files to *.js
coffee:
glob_to_multiple:
expand: true,
flatten: false, #here, it must be false to keep folder structure when compiling
cwd: 'src_client/',
src: ['**/*.coffee'],
dest: 'public/ppalmeida/',
ext: '.js'
希望它能帮助别人。
谢谢。哦,现在我明白了。答案就在我面前:只需将“flatte”属性更改为“false”,这样它将保留文件的路径,这样coffeescript将使用它进行编译,并保留文件夹结构:
# Create the 'coffee' task, to compile all *.coffee files to *.js
coffee:
glob_to_multiple:
expand: true,
flatten: false, #here, it must be false to keep folder structure when compiling
cwd: 'src_client/',
src: ['**/*.coffee'],
dest: 'public/ppalmeida/',
ext: '.js'
希望它能帮助别人。
多谢各位
# Create the 'coffee' task, to compile all *.coffee files to *.js
coffee:
glob_to_multiple:
expand: true,
flatten: false, #here, it must be false to keep folder structure when compiling
cwd: 'src_client/',
src: ['**/*.coffee'],
dest: 'public/ppalmeida/',
ext: '.js'