How to compile an Angular2 TypeScript application to a single file?

前端 未结 3 696
后悔当初
后悔当初 2021-02-04 13:56

I realize that I can compile my application with tsc my_app.ts --target system and it will generate a SystemJS-wrapped file for each imported module, which is aweso

3条回答
  •  青春惊慌失措
    2021-02-04 14:24

    You need to tell you tsc compailer where to put your js files after tsc compile (command: tsc -w). The two parameter in the tsconfig.js file tells TypeScript compailer to put all js out put into one file in a directory is

    "outDir":"dist/",
    "outFile": "dist/app.js"
    

    My full tsconfig.js is as below

    {
      "compilerOptions": {
        "target": "es5",
        "module": "system",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": false,
        "noImplicitAny": true,
        "suppressImplicitAnyIndexErrors": true,
        "outDir":"dist/",
        "outFile": "dist/app.js"
      }
    }
    

提交回复
热议问题