Cannot include .woff files into dist build directory when running tsc command

21 views Asked by At

I'm building a simple lambda function and i'm trying to include some statics font assets within the compiled directory.

I have created a .d.ts file inside the project with the image file extension, and included it inside tsconfig.json. However, when I run the tsc command to build the project, the fonts are nowhere to be found...

My project structure

+ dist
  + lambda
    - helper.js
    - index.js
    - types.js
+ src
  + fonts
    - my-font.woff
    - my-font.woff2
  + types
    - fonts.d.ts
  - helper.ts
  - index.ts
  - types.ts
- .eslintrc.json
- package.json
- tsconfig.json

My tsconfig.json file:

{
    "compilerOptions": {
        "target": "ES2018",
        "module": "commonjs",
        "rootDir": "src",
        "moduleResolution": "node",
        "resolveJsonModule": true,
        "outDir": "dist/lambda",
        "removeComments": true,
        "noEmitOnError": true,
        "esModuleInterop": true,
        "forceConsistentCasingInFileNames": true,
        "strict": true,
        "noImplicitAny": true,
    },
    "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*", "./src/**/*", "src/types", "src/types/fonts.d.ts"]
}

My /.eslintrc file:

{
    "env": {
        "es2021": true
    },
    "extends": [
        "eslint:recommended",
        "plugin:@typescript-eslint/eslint-recommended",
        "plugin:@typescript-eslint/recommended"
    ],
    "parser": "@typescript-eslint/parser",
    "parserOptions": {
        "ecmaVersion": "latest",
        "sourceType": "module",
        "project": "./tsconfig.json"
    },
    "plugins": ["@typescript-eslint"],
    "rules": {
        "@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }]
    }
}

My types/fonts.d.ts file:

declare module "*.woff";
declare module "*.woff2";

I'm expecting my dist structure to look something like this:

+ dist
  + lambda
    + fonts
      - my-font.woff
      - my-font.woff2
    - helper.js
    - index.js
    - types.js

I've tried renaming my fonts.d.ts file, i've changed how i'm including files in tsconfig.json to every variation i can think of. I've also tried different folder structures and filenames for the fonts themselves and varaitions or requiring and importing them in the index.ts file.

I've even tried adding "types": "/fonts.d.ts" to my package.json file

I've tried just about everything i can think of and everything i can find on google and i'm stumped... The worse part is i'm almost certain it's going to be something really obvious!

0

There are 0 answers