Home

Issue: 1052

Add publicPath type of option to generate

[issue link]

Hi!

I tried to publish generated Nuxt page to Github pages. It is served from a subdirectory: username.gihub.io/projectname. This causes 404s because asset references start with ‘/’. For example _nuxt folder:
Failed to load resource: the server responded with a status of 404 (Not Found) /_nuxt/1.nuxt.bundle.5b7c88cf02a549fbbf73.js

The path should be: /projectname/_nuxt/1.nuxt.bundle.5b7c88cf02a549fbbf73.js
Or: _https://username.gihub.io/projectname/nuxt/1.nuxt.bundle.5b7c88cf02a549fbbf73.js

I couldn’t find any good workaround.

It seems that $ nuxt build has a publicPath option that allows changing the dist folder location. It would be great to have similar option for $nuxt generate also. Default could be ‘/’ but changing it to ‘/projectname/’ would solve the problem in Github pages case. This path should also be prepended in the head section of nuxt.config.js where references to local files are made.

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