The srcDir property

Define the source directory of your Nuxt application.


If a relative path is specified it will be relative to the rootDir.

Example 1: Prerequisites:

nuxt.config.js

  1. export default {
  2. srcDir: 'client/'
  3. }

package.json

  1. "script": {
  2. "dev": "yarn nuxt"
  3. }

works with the following folder structure (note that nuxt.config is listed in the app directory)

  1. -| app/
  2. ---| node_modules/
  3. ---| nuxt.config.js
  4. ---| package.json
  5. ---| client/
  6. ------| assets/
  7. ------| components/
  8. ------| layouts/
  9. ------| middleware/
  10. ------| pages/
  11. ------| plugins/
  12. ------| static/
  13. ------| store/

Example 2:

Instead of example 1 you can also move the nuxt.config into your client folder. In this case you only need to specify client as the rootDir and you can leave srcDir empty:

Prerequisites:

nuxt.config.js

  1. export default {
  2. srcDir: '' // or just remove it
  3. }

package.json

  1. "script": {
  2. "dev": "yarn nuxt client" // this sets client as the rootDir
  3. }

works with the following folder structure (note that nuxt.config is listed in the client directory)

  1. -| app/
  2. ---| node_modules/
  3. ---| package.json
  4. ---| client/
  5. ------| nuxt.config.js
  6. ------| assets/
  7. ------| components/
  8. ------| layouts/
  9. ------| middleware/
  10. ------| pages/
  11. ------| plugins/
  12. ------| static/
  13. ------| store/