【发布时间】:2026-02-05 02:40:01
【问题描述】:
我有以下目录结构:
root
|
|_ package.json
|_ Gruntfile.js
|
|_ javascripts/
|_ ts/file.ts
在 Gruntfile 我有这个:
//Project Config
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
typescript: {
base: {
src: ['./javascripts/ts/*.ts'],
dest: './javascripts/'
}
}
});
我希望 js 文件位于 javascripts/ 目录中。但是,当我运行 grunt typescript 时,它会创建这个奇怪的目录结构:
root
|
|_ package.json
|_ Gruntfile.js
|
|_ javascripts/
|_ ts/file.ts
|_ javascripts/
|_ ts/
|_ file.js
我希望编译后的file.js 出现在原始javascripts/ 目录中。
为什么会这样?我应该写什么才能在所需文件夹中编译 .js 文件?
【问题讨论】:
-
我写了 grunt-ts。试一试。只是说;)
-
@basarat
grunt-ts确实解决了这个问题!
标签: javascript node.js typescript gruntjs