API: The srcDir Property

Define the source directory of your Nuxt.js application

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

Example 1:Prerequisites:

  1. // nuxt.config.js
  2. export default {
  3. srcDir: 'client/'
  4. }
  5. // package.json
  6. "script": {
  7. "dev": "yarn nuxt"
  8. }

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 src folder. In this case you only need to specify client as the rootDir and you can leave srcDir empty:

Prerequisites:

  1. // nuxt.config.js
  2. export default {
  3. srcDir: '' // or just remove it
  4. }
  5. // package.json
  6. "script": {
  7. "dev": "yarn nuxt client" // this sets client as the rootDir
  8. }

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/