Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include CSS files in tsc TypeScript compilation

I am trying to create a React TypeScript NPM package. I have finished my code and created package.json and tsconfig.json. But inside my package I also have a bunch of CSS files that I want to include in my package. This is my tsconfig.json:

{
  "compilerOptions": {
    "outDir": "./dist",
    "target": "es5",
    "esModuleInterop": true,
    "module": "commonjs",
    "moduleResolution": "node",
    "noImplicitAny": true,
    "removeComments": true,
    "declaration": true,
    "jsx": "react",
    "lib": [ "es2015", "dom" ],
    "sourceMap": false
  },
  "files": [
    "src/index.tsx"
  ],
  "include": [
    "src/**/*"
  ],
  "exclude": [
    "node_modules"
  ]
}

My problem is that when I run tsc in my folder, it creates all .js files and all .d.ts files in /dist, but I see no CSS files at all. How do I do to make it include CSS?

like image 724
BluePrint Avatar asked Dec 06 '19 12:12

BluePrint


People also ask

What does TSC do in TypeScript?

Tsc stands for `TypeScript compiler` and is a simple tool included in Typescript itself, allowing you to compile any ts files into js.

What is TSC TypeScript compiler?

TypeScript is a superset of Javascript and supports the Object-Oriented Concept. In TypeScript, whenever we compile our code of file type . ts it gets converted into a . js file by using tsc compiler. It means that the TypeScript code get trans-compiled into plain JavaScript.

How are TypeScript files compiled?

TypeScript provides a command-line utility tsc that compiles (transpiles) TypeScript files ( . ts ) into JavaScript. However, the tsc compiler (short for TypeScript compiler) needs a JSON configuration file to look for TypeScript files in the project and generate valid output files at a correct location.


1 Answers

So this is exactly the question I was looking for. Unfortunately for us both I found our answer in this post https://vccolombo.github.io/blog/tsc-how-to-copy-non-typescript-files-when-building/

Basically what it said was that tsc does not do anything other than turn TS code into JS code and there are no plans to change this in the future.

like image 58
tacodave Avatar answered Sep 28 '22 00:09

tacodave