Skip to content

Devserver has problems serving static assets with assetsPublicPath != '/' #1176

Closed
@jbayona89

Description

@jbayona89

Hello I have made a Vuetify app using vue-cli and vue init vuetifyjs/webpack-advanced the resulting code is this https://github.com/vuetifyjs/webpack-advanced/tree/master/template

The problem I have is that my production app isn't in the root of the server and it is a subpath in www.example.com/foo. When I run npm run build all my static assets like images and fonts are referenced like /static/images/example.png, so the server doesn't find them as they are being looked in www.example.com/static/images/example.png instead of www.example.com/foo/static/images/example.png

If I change config/index.js and set assetsPublicPath: '/foo' and change all my references from /static/... to /foo/static/... then my production server finds all my static assets but then my dev server using npm run dev can't find them as they are being referenced as localhost:8080/foo/static/images/example.png but they seem to be at localhost:8080/static/images/example.png for some reason.

My ideal solution would be just to keep the references as /static and tell webpack or vueloader somehow that on npm run build it should prepend /foo to all of my assets urls. If that is impossible at least I would like to know a way to make my dev and production environments to work with the same code even though it implies to prepend manually /foo to my static assets urls

Thank you

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions