Skip to content

Commit ad26a7f

Browse files
authored
Merge pull request #384 from vinitkumar/upgrade-to-tailwind-and-vanilla-js
fix: prevent loading .map files and disable source maps in production
2 parents c2c7fa9 + 9c1a0a1 commit ad26a7f

File tree

4 files changed

+18
-26
lines changed

4 files changed

+18
-26
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"private": false,
77
"author": "Vinit Kumar <[email protected]> (http://vinitkumar.me)",
88
"scripts": {
9-
"build": "tsc",
9+
"build": "tsc -p tsconfig.prod.json",
10+
"build:dev": "tsc",
1011
"start": "ts-node server.ts",
1112
"start:prod": "node dist/server.js",
1213
"dev": "nodemon --exec ts-node server.ts",

server.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,13 @@ const connect = async (): Promise<typeof mongoose> => {
7070

7171
const modelsPath = __dirname + '/app/models';
7272
fs.readdirSync(modelsPath).forEach((file) => {
73-
require(modelsPath + '/' + file);
73+
// Only load .js or .ts files, skip .map and other files
74+
if (file.endsWith('.js') || file.endsWith('.ts')) {
75+
// Skip .d.ts declaration files
76+
if (!file.endsWith('.d.ts')) {
77+
require(modelsPath + '/' + file);
78+
}
79+
}
7480
});
7581

7682
passportConfig(passport, cfg);

tsconfig.prod.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"sourceMap": false,
5+
"declaration": false,
6+
"declarationMap": false
7+
}
8+
}
9+

vercel.json

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,9 @@
55
{
66
"src": "dist/server.js",
77
"use": "@vercel/node"
8-
},
9-
{
10-
"src": "public/**",
11-
"use": "@vercel/static"
128
}
139
],
1410
"routes": [
15-
{
16-
"src": "/css/(.*)",
17-
"dest": "/public/css/$1"
18-
},
19-
{
20-
"src": "/js/(.*)",
21-
"dest": "/public/js/$1"
22-
},
23-
{
24-
"src": "/img/(.*)",
25-
"dest": "/public/img/$1"
26-
},
27-
{
28-
"src": "/font/(.*)",
29-
"dest": "/public/font/$1"
30-
},
31-
{
32-
"src": "/webfonts/(.*)",
33-
"dest": "/public/webfonts/$1"
34-
},
3511
{
3612
"src": "/(.*)",
3713
"dest": "/dist/server.js"

0 commit comments

Comments
 (0)