This project is using domain-based directory architecture. As such, it utilizes Nuxt3 Layer
concept to encapsulate
code instead of module.
.
├── core # Core project (shared setup)
│ ├── components # Common components shared by domains
│ ├── composables # Common composables shared by domains
│ ├── layouts # Common layout shared by domains
│ ├── plugins # Common plugins shared by domains
│ ├── public # Public assets served at server root
│ ├── stores # Common store shared by domains
│ └── nuxt.config.ts # (Required) Core-specific nuxt config
├── ui # UI library project
│ ├── components # Common components shared by domains
│ └── nuxt.config.ts # (Required) UI-specific nuxt config
├── layers # Domain-based project holder
│ └── <domain_name> # Domain-bsaed project (feature-based)
│ ├── components # Domain-specific components
│ ├── pages # Domain-specific pages
│ │ └── <domain_path> # Domain-specific base path (ie. domain.com/<domain_path>/)
│ ├── config # Domain-specific config (constants, flags, etc)
│ └── nuxt.config.ts # (Required) Domain-specific nuxt config
├── public # Public assets served at server root
├── nuxt.config.ts # Root nuxt config
└── README.md
Follow this step when you need to create a new feature. For example, we are going to work on a feature called "Shop":
- Create a new layer project under
layers
folder with the command below
npx nuxi init --template layer layers/<layer_project_name>
- Remove unnecessary files and folder. In common setup, removing files directly in the root
feature
folder is fine exceptnuxt.config.ts
. - Add layer paths to
nuxt.config.ts
in the project root folder. - Restart server.
⚠️ Changes tonuxt.config.ts
, especially in layers, may not be picked up by Nuxt, so make sure to restart server manually if making any changess to nuxt config or app config to prevent working on obsolete setup
ℹ️ Running the command in step 1 is optional. You can also manually create each folders as needed,
ie. when working with feature A, we only needed components and pages. We could just make folder
FeatureA
underlayers
and alsocomponents
andpages
underFeatureA
.However, make sure to add
nuxt.config.ts
orpages
may not get picked up by Nuxt
When updating eslint config, make sure to commit the change on its own (not mixed with other files) as in order for it to have an effect, devs may need to clear installed packaged and reinstall them.
You can run the command below (assuming on UNIX-based OS and using npm
as package manager)
rm -rf node_modules && npm i
Date | Author | Notes |
---|---|---|
03-09-2024 | Gretta | Added Folder Structure , Working on new feature , Updating eslint rules |