mtbno
mtbno

Reputation: 598

Nuxt.js - is it possible to set custom path/base to staticfiles' urls?

TLDR;

How to change staticfiles path from src="/_nuxt/<file>" to e.g. src="/static/frontend/<file>" in Nuxt generated files?


Recently I've started a project using Nuxt.js and Django framework. Simply explained, with Nuxt I generate the dist/ - my frontend app, and then copy it with Node.js to Django's static folder to be served.

In Django, the static files come built with a different path e.g /static/frontend/<filename>.js. However when I use nuxt generate to generate my app, there is - naturally - a path to files within the dist folder, in my case it's /_nuxt/<filename>.js/.

Is it possible to modify this "prefix" in nuxt.config.js? So far I know only about this option to set the base path for the whole app:

// nuxt.config.js

router: {
    base: '/app/'
},

But this is not a solution for me. Until now I have to replace the path occurences manually with Node.js and it might make things a bit messy. Any help appreciated!

Upvotes: 1

Views: 7571

Answers (1)

mtbno
mtbno

Reputation: 598

As @Lawrence Cherone mentioned, publicPath is the answer.

Upvotes: 1

Related Questions