Skip to content

Instantly share code, notes, and snippets.

@thisismydesign
Last active September 6, 2023 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thisismydesign/70d21090021f9304d00cafdea56d936b to your computer and use it in GitHub Desktop.
Save thisismydesign/70d21090021f9304d00cafdea56d936b to your computer and use it in GitHub Desktop.
NestJS + Next.js /4 Folder structure & config
// 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': '^_' }]
},
};
// nest-cli.json
{
"sourceRoot": "src/server"
}
/// <reference types="next" />
/// <reference types="next/types/global" />
// ^ Put this in src/client/next-env.d.ts
// 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',
};
// package.json
{
"scripts": {
"build": "nest build && cd src/client && next build",
}
}
// Edit your Nest TypeScript config in the root dir (tsconfig.json) to only apply to the server code
{
"include": ["src/server"],
}
// 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