Last active
September 6, 2023 12:43
-
-
Save thisismydesign/70d21090021f9304d00cafdea56d936b to your computer and use it in GitHub Desktop.
NestJS + Next.js /4 Folder structure & config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/client/.eslintrc.js | |
// Your custom ESLint file for React, applied only to src/client automatically | |
module.exports = { | |
parser: '@typescript-eslint/parser', | |
parserOptions: { | |
project: 'src/client/tsconfig.json', | |
sourceType: 'module', | |
}, | |
plugins: ['@typescript-eslint/eslint-plugin'], | |
extends: [ | |
'plugin:@typescript-eslint/recommended', | |
'prettier/@typescript-eslint', | |
'plugin:prettier/recommended', | |
], | |
root: true, | |
env: { | |
jest: true, | |
}, | |
ignorePatterns: ['.eslintrc.js'], | |
rules: { | |
'@typescript-eslint/interface-name-prefix': 'off', | |
'@typescript-eslint/explicit-function-return-type': 'off', | |
'@typescript-eslint/explicit-module-boundary-types': 'off', | |
'@typescript-eslint/no-explicit-any': 'off', | |
'@typescript-eslint/no-unused-vars': ['warn', { 'argsIgnorePattern': '^_' }] | |
}, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// nest-cli.json | |
{ | |
"sourceRoot": "src/server" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference types="next" /> | |
/// <reference types="next/types/global" /> | |
// ^ Put this in src/client/next-env.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Put this in src/client/next.config.js | |
// This is so .next folder is in the root directory. Make sure to add .next to .gitignore | |
module.exports = { | |
distDir: '../../.next', | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// package.json | |
{ | |
"scripts": { | |
"build": "nest build && cd src/client && next build", | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Edit your Nest TypeScript config in the root dir (tsconfig.json) to only apply to the server code | |
{ | |
"include": ["src/server"], | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
// Your custom TypeScript config for React, applied only to src/client automatically | |
// Put this in src/client/tsconfig.json | |
{ | |
"compilerOptions": { | |
"target": "es5", | |
"lib": [ | |
"dom", | |
"dom.iterable", | |
"esnext" | |
], | |
"allowJs": true, | |
"skipLibCheck": true, | |
"strict": false, | |
"forceConsistentCasingInFileNames": true, | |
"noEmit": true, | |
"esModuleInterop": true, | |
"module": "esnext", | |
"moduleResolution": "node", | |
"resolveJsonModule": true, | |
"isolatedModules": true, | |
"jsx": "preserve" | |
}, | |
"include": [ | |
"next-env.d.ts", | |
"next.config.js", | |
"pages/**/*.ts", | |
"pages/**/*.tsx" | |
], | |
"exclude": [ | |
"node_modules" | |
] | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment