Karl B.
Karl B.

Reputation: 263

VueJS CLI Webpack static folder not working when in subfolder

i'm using the vuejs cli webpack template. My URL's are not working properly, for example:

<link rel="..." href="/static/img/favicons/apple-icon-57x57.png">

This works fine on my development server, but not on my production server -> (404 file not found).
And if i try this on my dev server:

$.ajax({
        type: 'POST',
        url: '/static/php/process.php',
        data: term_formData
    })

(main.js), url not working.(404 file not found)

I already changed the webpack option: assetsPublicPath.

The Webpack config/index.js file:

  build: {
    // Template for index.html
    index: path.resolve(__dirname, '../dist/index.html'),

    // Paths
    assetsRoot: path.resolve(__dirname, '../dist'),
    assetsSubDirectory: 'static',

assetsPublicPath: '/vueapp/dist/',

    ...

Production server: http://localhost/vueapp/dist/
Development server: http://localhost:8080/

Thanks in advance =)

Upvotes: 0

Views: 1857

Answers (1)

connexo
connexo

Reputation: 56744

Set assetsSubDirectory: './static'. This happens because you haven't placed your application in the web root, which the template assumes. The other solution is to make vueapp/dist your web root in your Apache/Nginx config.

Upvotes: 1

Related Questions