✨ This workspace has been generated by Nx, a Smart, fast and extensible build system. ✨
Run nx graph
to see a diagram of the dependencies of the projects.
Run npx nx connect-to-nx-cloud
to enable remote caching and make CI faster.
- linter for all project
nx run-many --all --target=lint
- fix errors and warn in all project
nx run-many --all --target=lint --fix
- linter for special project
nx lint <project-name>
- prettier check files
nx format:check
- prettier write files
nx format:write
-
for create library
nx g @nrwl/react:lib my-lib --bundler=vite
-
for create apps
nx g @nrwl/react:app my-app --bundler=vite
-
when creating a package for check type should add an executor to
project.json
"type-check": { "executor": "nx:run-commands", "options": { "commands": [ "tsc -p libs/<project-name>/tsconfig.lib.json --noEmit", "tsc -p libs/<project-name>/tsconfig.spec.json --noEmit" ] } },
-
To implement a semantic version for the new package should be added version to the
project.json
file"version": { "executor": "@jscutlery/semver:version", "options": { "baseBranch": "dev", "preset": "conventional", "tagPrefix": "${projectName}@" } }
-
To support
.tsx
files should be added below code totsconfig.spec.json
for jest config{ "extends": "./tsconfig.json", "compilerOptions": { "allowUmdGlobalAccess": true, "outDir": "../../dist/out-tsc", "module": "commonjs", "types": ["jest", "node"] }, "include": [ "jest.config.ts", "jest.setup.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.spec.ts", "src/**/*.d.ts" ] }
-
add
import "@testing-library/jest-dom"
intojest.setup.ts
-
add
setupFilesAfterEnv: ["./jest.setup.ts"]
intojest.config.ts
- initial jest for packages
nx g @nrwl/jest:jest-project --project=<project-name>
- run jest
nx test <project-name>
- run jest watch mode
nx test <project-name> --watch
- update snapshot jest
nx test <project-name> -u
- report snapshot coverage
nx affected:test --codeCoverage
- start storybook in develop mode
nx run-many --target=dev
- add version to special package
nx run <project-name>:version
- add version to all packages
nx run-many --all --target=version
- commit type
fix
ispatch
version - commit type
feat
isminor
version - commit body contains the text
BREAKING CHANGE
ismajor
version - force a patch increment even if library source didn't change
--allowEmptyRelease
- push tags to git with
git push --tags
- add new rule to pre-commit
npx husky add .husky/pre-commit 'echo rule'
- destory project in nx framework
nx generate remove <project-name>
Visit the Nx Documentation to learn more.