Nuxt.js: proposal: Add `sub directory` config in nuxt.config.js

Created on 3 Nov 2017  路  8Comments  路  Source: nuxt/nuxt.js

Hi, I maintain multiple Web sites with subdirectory structure created by Nuxt.
(e.g. https://push7.jp/docs )

Then, I have a problem with such a site.

Nuxt build andgenerate are excellent, but they are always made to refer to the .nuxt directory for the root directory.

I solve this by linking with a shell script etc, but it is not a good idea.

To solve this problem, I would like to add a function that can manage the target directory with the configuration called subdirectory as Nuxt's function.

In particular, in Japan such a URL structure is very popular, so there are many opportunities to use.

If this proposal is allowed, I would like to implement it even soon!

Config sample

in nuxt.config.js

{
  ...
  subdirectory: Boolean | String
  ...
}
{
  ...
  subdirectory: false // default
  ...
}
{
  ...
  subdirectory: '/blog/'
  ...
}

This question is available on Nuxt.js community (#c1795)

Most helpful comment

Have you tried the Vue Router Base Property?

module.exports = {
  router: {
    base: '/app/'
  }
}

https://nuxtjs.org/api/configuration-router/

All 8 comments

Have you tried the Vue Router Base Property?

module.exports = {
  router: {
    base: '/app/'
  }
}

https://nuxtjs.org/api/configuration-router/

I'm not sure if I understand you correctly, but maybe buildDir is what you are looking for?

buildDir: './nuxt/blog' // default: './nuxt'

@christophwolff @KonstantinVlasov
Thanks feedback!

But, It seems to be a little different from what I'm seeking.

I need

<link href="/blog/_nuxt/manifest.bdb5daca1950a978e030.js" rel="preload" as="script">

nuxt generate result

<link href="/_nuxt/manifest.bdb5daca1950a978e030.js" rel="preload" as="script">

Is it possible to add a path before /_nuxt ?

I think publicPath can help you

@KonstantinVlasov
I have tried it in the past.
But, It was a little different from what I wanted.

I am hosting another web site directly under the domain and /docs.

result:

screen shot 2017-11-05 at 21 59 17

I need:

screen shot 2017-11-05 at 21 59 27

see https://nuxtjs.org/faq/github-pages and also https://nuxtjs.org/api/configuration-build#publicpath

That should resolve it for you. Closing. Reopen if still not clear.

I think this proposal is valid and necessary, you not always want to publish in the root directory, publish path solve the problem but you need to change your image routes. with this helper you may decide where you want to publish (main domain or a folder) with just one config.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pehbehbeh picture pehbehbeh  路  3Comments

shyamchandranmec picture shyamchandranmec  路  3Comments

mattdharmon picture mattdharmon  路  3Comments

o-alexandrov picture o-alexandrov  路  3Comments

surmon-china picture surmon-china  路  3Comments