Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typescript copy-files

In my project I'm having a src and a dist folder. In src are all the ts, json and css files.

In the tsconfig I specified the outDir to be dist. Is it know possible to copy all the json and css files also to the dist folder (like in Babel with the --copy-files parameter)?

like image 634
pck Avatar asked Apr 18 '16 09:04

pck


People also ask

How do I copy a file in FS?

The fs. copyFile() method is used to asynchronously copy a file from the source path to destination path. By default, Node. js will overwrite the file if it already exists at the given destination.


2 Answers

It is not possible. Typescript's philosophy is to do one thing and do it well. This is relegated to transpiling Typescript to Javascript. The project has also denied requests to add source code formatting controls because there are other tools that handle that better. What this means is that if you need anything outside of transpiling, you will need a workflow to handle the other functionality/needs.

like image 185
ArcSine Avatar answered Oct 09 '22 09:10

ArcSine


You can use tools like gulp/grunt to tailor your building process to your needs.

For example, using gulp task to copy all non ts files can look like this:

gulp.task('build.copy.assets', 
function() 
{
    return gulp.src(['./src/**/*', '!./**/*.ts'])
            .pipe(gulp.dest('dist'));
});
like image 29
Amid Avatar answered Oct 09 '22 09:10

Amid