Skip to content

Commit e71ca8d

Browse files
author
Burhan
committed
README.md/custom.d.ts/tsconfig.json - Inclued logic that should help starter project use svg files
1 parent e52af1c commit e71ca8d

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,33 @@ npm run start
269269
npm run build
270270
```
271271
29. Now you can see the program dynamically created the "public" folder which contains the unique hashed id bundles of compiled JavaScript, css, and other files.
272+
30. Sometimes svg files and content wont work correctly with tsx and webpack out of the box. We need to include a special file in the root directory called **custom.d.ts** which will contain some configuration rules.
273+
```javascript
274+
declare module "*.svg" {
275+
const content: any;
276+
export default content;
277+
}
278+
```
279+
31. You will also need to include the newly crated **custom.d.ts** file in the **tsconfig.json** file for TypeScript to work properly with svg.
280+
```json
281+
{
282+
"compilerOptions": {
283+
"module": "CommonJS",
284+
"jsx": "react",
285+
"watch": true,
286+
"target": "es5",
287+
"lib": [
288+
"es6",
289+
"dom"
290+
]
291+
},
292+
"include": [
293+
"./src",
294+
"./custom.d.ts"
295+
]
296+
}
297+
```
298+
272299

273300
##### References used to create this program
274301
##### * [Chris Hawkes](https://www.youtube.com/watch?v=nCoQg5qbLcY)

custom.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module "*.svg" {
2+
const content: any;
3+
export default content;
4+
}

tsconfig.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,9 @@
88
"es6",
99
"dom"
1010
]
11-
}
11+
},
12+
"include": [
13+
"./src",
14+
"./custom.d.ts"
15+
]
1216
}

0 commit comments

Comments
 (0)