k-maru / grunt-typescript

MIT License
137 stars 60 forks source link

Creates src folders #95

Open iamdriz opened 9 years ago

iamdriz commented 9 years ago

I have the following structure:

/app
-- /src
---- /js
------ /file1.js
------ /file2.js
---- /ts
------ /file1.ts
------ /file2.ts
-- /js
---- /file1.js
---- /file2.js

So my uncompiled JS and TS files sit inside the /src folder and then are compiled into the main /js folder as follows:

The typescript plugin should be compiling the TS files into JS files into the /src/js folder using:

typescript: {
    base: {
        src: ['src/ts/**/*.ts'],
        dest: 'src/js/'
    }
},

and then compile the newly compiled JS files in /src/js into the main /js folder with:

uglify: {
    options: {
        mangle: true,
        sourceMap: true
    },
    my_target: {
        files: [{
            expand: true,
            cwd: 'src/js/',
            src: '**/*.js',
            dest: 'js/'
        }]
    }
},

But what happens, is the typescript plugin creates a /src/ts/ folder in both JS folders! The uglify plugin works fine and isn't the cause of this issue.

So I end up with:

/app
-- /src
---- /js
------ /file1.js
------ /file2.js
------ /src
-------- /ts
---------- /file1.js
---------- /file2.js
---- /ts
------ /file1.ts
------ /file2.ts
-- /js
---- /file1.js
---- /file2.js
---- /src
------ /ts
-------- /file1.js
-------- /file2.js

How do I stop this? It seems like the typescript plugin doesn't know where the paths are... and ends up creating a right mess of the directories and creating too many JS files

Gruntfile.js is in the /app folder.

Update: I've ended up using this plugin instead: https://www.npmjs.com/package/grunt-typescript-compile which doesn't have this problem, perhaps you could borrow some code that fix this issue in this plugin? Thanks :)