Alexander Trauzzi
Alexander Trauzzi

Reputation: 7395

Is it possible to include JavaScript files as part of my build?

Is it possible to put a reference in my code to .js files and have typescript combine them as part of its final build?

What I'm trying to obviate here is the need for any tools that do combining, script tags, or requiring a loader when all I'm producing are internal modules.

Note: I am not talking about .d.ts files which I'm aware of. I'm looking for ways to include the actual JavaScript files in the .js output from tsc.

Upvotes: 17

Views: 20449

Answers (1)

leogoesger
leogoesger

Reputation: 3840

I tried to include js file with this, and it worked. The js files are added to the build folder.

{
    "compilerOptions": {
        ...
        "allowJs": true,
        "outDir": "./build/",
        ...
    },
    "include": ["src/**/*"],
    "exclude": ["node_modules", "**/*.spec.ts"]
}

Upvotes: 35

Related Questions