Coffeescript 如何设置GrunFile以使编译后的文件与其源文件位于同一目录中
我正在做一个非常旧的项目,它使用了Grunt 0.3和Coffee,我需要将它更新到这两个版本的更新版本,但我对Grunt不是特别熟悉。以前,Grunt会将.js文件编译到与源.coffee文件完全相同的文件夹和名称,我需要保持这种方式。但是,我在配置任务时遇到问题。这就是我现在拥有的:Coffeescript 如何设置GrunFile以使编译后的文件与其源文件位于同一目录中,coffeescript,gruntjs,grunt-contrib-watch,grunt-contrib-coffee,Coffeescript,Gruntjs,Grunt Contrib Watch,Grunt Contrib Coffee,我正在做一个非常旧的项目,它使用了Grunt 0.3和Coffee,我需要将它更新到这两个版本的更新版本,但我对Grunt不是特别熟悉。以前,Grunt会将.js文件编译到与源.coffee文件完全相同的文件夹和名称,我需要保持这种方式。但是,我在配置任务时遇到问题。这就是我现在拥有的: coffee: { options: { bare: true, sourceMap: true, expand: true, flatten: false, cwd: '.', s
coffee: {
options: {
bare: true,
sourceMap: true,
expand: true,
flatten: false,
cwd: '.',
src: ['**/*.coffee'],
dest: '.',
ext: ".js"
}
}
这是我得到的信息:
C:\projetos\sesc-bertioga\bertioga-server\src\main\webapp (newGrunt -> origin) (sesc-bertioga@1.0.0)
λ grunt watch
Running "watch" task
Waiting...
>> File "public\javascript\app\views\solicitacao_grupo\tripulacao_view.coffee" changed.
>> No "coffee" targets found.
Warning: Task "coffee" failed. Use --force to continue.
I绝对无法更改输出位置,新文件必须与原始文件位于同一目录中。你有什么想法吗?因此,经过一点修补,我的一位朋友想出了这个主意,以防有人遇到类似的问题
coffee: {
files: {
expand: true,
cwd: 'public/javascript/app',
src: ['**/*.coffee'],
dest: 'public/javascript/app/',
ext: '.js',
rename: (dest, src) => {
return (dest + src.replace('coffee', 'js'))
}
},
options: {
bare: false,
sourceMap: false,
flatten: false,
app: {
src: ['public/javascript/app/**/*.coffee'],
}
}
}
无论如何,谢谢=)所以经过一点修补,我的一个朋友想出了这个,以防有人有类似的问题
coffee: {
files: {
expand: true,
cwd: 'public/javascript/app',
src: ['**/*.coffee'],
dest: 'public/javascript/app/',
ext: '.js',
rename: (dest, src) => {
return (dest + src.replace('coffee', 'js'))
}
},
options: {
bare: false,
sourceMap: false,
flatten: false,
app: {
src: ['public/javascript/app/**/*.coffee'],
}
}
}
无论如何,谢谢=)