简体   繁体   中英

grunt-typescript doesn't produce js files in specified `dest`

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?

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

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'
            }
        }
    }       
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM