Clément Flodrops
Clément Flodrops

Reputation: 1104

Vuejs in production: prefix static path

Context

I'm building a VueJS app and I would like to push it in production. I've generated files using npm run build and I've uploaded those on a server (IIS).

I have a lot of other applications on this server and I can't change how it works.

Here is a fake example to help me explain my issue:

mydomain.com/app1 will redirect to a web-app under a folder app1. To add my VueJS project I've created a new folder - lets say vueapp - and I get access it via mydomain.com/vueapp.

The thing is : the static paths generated by vue are not prefixed by vueapp. Paths in index.html are not like I want : I get mydomain.com/static/** instead of mydomaim.com/vueapp/static/** for a vue request.

I would like to tell webpack to prefix index.html's path by something but I can't get it work.

assetsSubDirectory

config/build.js gives us the possibility to change the assets sub directory (which is static by default). So I can set it to vueappPrefix/static but of course, this doesn't work.

This is obvious.

Of course I can edit index.html by hand or add a script to do it but I would like to know if there is a cleaner way to do this.

Thanks a lot.

Upvotes: 7

Views: 6131

Answers (1)

Luis Orduz
Luis Orduz

Reputation: 2887

Changing the assetsPublicPath works for me.

In this case, it'd be:

assetsPublicPath: '/vueapp/'

UPDATE (11/20): To do the same in newer versions of vue-cli, there's an option mentioned in the comments.

Upvotes: 9

Related Questions