Reputation: 14269
I have the following directory structure :
root
|
|_ package.json
|_ Gruntfile.js
|
|_ javascripts/
|_ ts/file.ts
In the Gruntfile I have this:
//Project Config
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
typescript: {
base: {
src: ['./javascripts/ts/*.ts'],
dest: './javascripts/'
}
}
});
I expect the js files to be in javascripts/
directory. However when I run grunt typescript
, it creates this weird directory structure:
root
|
|_ package.json
|_ Gruntfile.js
|
|_ javascripts/
|_ ts/file.ts
|_ javascripts/
|_ ts/
|_ file.js
I expect the compiled file.js
to appear in the original javascripts/
directory.
Why is this so? What should I write to get compiled .js
files in desired folder?
Upvotes: 6
Views: 2059
Reputation: 9322
Another option is to make use of the base_path
config:
//Project Config
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
typescript: {
base: {
src: ['./javascripts/ts/*.ts'],
dest: './javascripts/',
options: {
base_path: './javascripts/ts'
}
}
}
});
Upvotes: 1
Reputation: 275857
Seeing the output I would assume the following will work:
typescript: {
base: {
src: ['./javascripts/ts/*.ts'],
dest: '../../javascripts/'
}
}
Personally I authored and maintain grunt-ts
: https://npmjs.org/package/grunt-ts
Upvotes: 5