- NPM workspaces to manage monorepo
- Full Stack: Front-end, Back-end, Shared/Utils module packages
- Front-end package: Vue 3 | Vite
- Back-end package: NestJS | nest-cli
- Shared package: shared code used in both front-end and backend-end
- Utils package: shared code used in all packages
- Configure NPM workspaces
- Configure .gitignore
- Configure global tsconfig related to apps and libs
- Create npm scripts
- Configure ESLint
- Script to create binaries from apps
Suggest to install nest-cli globally in dev environment.
# 1. Clone the repository
git clone https://github.com/DhivinX/monorepo-ts-vue-nestjs.git project-name
# 2. Enter your newly-cloned folder
cd project-name
# 3. Install the project and build packages in libs folder
npm install
# 4. Dev: Run frontend with hot reload
npm run web:dev
# 5. Dev: Run backend with hot reload
# Note that you need to create the config.yaml file in the server directory beforehand
# You can copy the config.example.yaml file and rename it to config.yaml
# Then you can configure database access and other server settings
npm run server:dev
# HTTP / HTTPS server settings
http:
# If you change the server port you have to change it also on the front-end
port: 3000
# If true it starts the HTTPS server
# Note that you need to fill in the credentials fields for the SSL certificate
secure: false
# If secure option is set to true you must define the paths for the SSL certificate
credentials:
key: 'PATH_TO_KEY_DIR/key.pem'
cert: 'PATH_TO_CERT_DIR/cert.pem'
# Cross-Origin Resource Sharing domain origins
# More info: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
cors:
- 'http://localhost:8080'
# Database server settings
# More info: https://typeorm.io
db:
# Database type (postgres, mysql etc.)
type: 'postgres'
# Database server address
host: 'localhost'
# Database server port
port: 5432
# Database name
database: ''
# Database username
username: ''
# Database password
password: ''
# Disable this in the production version of the application
synchronize: true
# Keys required for hashing passwords and tokens
# They should be filled with random, unique strings
keys:
pwdsalt: ''
jwt: ''
- Install Volar extension
- In your project workspace, bring up the command palette with Ctrl + Shift + P (macOS: Cmd + Shift + P).
- Type built and select "Extensions: Show Built-in Extensions".
- Type typescript in the extension search box (do not remove @builtin prefix).
- Click the little gear icon of "TypeScript and JavaScript Language Features", and select "Disable (Workspace)".
- Reload the workspace. Takeover mode will be enabled when you open a Vue or TS file.
More info here: https://vuejs.org/guide/typescript/overview.html#takeover-mode
apps:dev
- run front-end and back-end simultaneously with hot reloadlibs:dev
- run all lib packages simultaneously with hot reloadweb:dev
- run front-end with hot reloadserver:dev
- run back-end with hot reloadserver:cli
- run back-end consolelibs:build
- build packages inlibs
folderbuild
- build all packagesclean
- clean all packageslint
- lint all packages
{
"recommendations": [
"vue.volar",
"dbaeumer.vscode-eslint",
"editorconfig.editorconfig",
"syler.sass-indented",
"eamodio.gitlens",
"donjayamanne.githistory",
"aaron-bond.better-comments",
"visualstudioexptteam.vscodeintellicode",
"pkief.material-icon-theme",
]
}
vue.volar
- Vue Language Features (Volar)syler.sass-indented
- Sass syntax highlighting.dbaeumer.vscode-eslint
- VS Code ESLint extension.editorconfig.editorconfig
- EditorConfig for VS Code.
eamodio.gitlens
- GitLens - Git supercharged.donjayamanne.githistory
- Git Historyvisualstudioexptteam.vscodeintellicode
- IntelliCodepkief.material-icon-theme
- Material Icon Theme in VS Codeaaron-bond.better-comments
- Better Comments
Disables top-level scripts for packages from the npm script panel.
{
"npm.exclude": [
"**/apps/**",
"**/libs/**",
]
}
If you find a bug, or have an enhancement in mind please post issues on GitHub.
MIT