A
A
Alex Wells2017-08-14 19:16:10
webpack
Alex Wells, 2017-08-14 19:16:10

Laravel-mix not loading paths correctly?

Hello. I use laravel which comes with laravel-mix. It is built on top of webpack.
At the end of the config I have a few lines:

if (mix.config.inProduction) {
    mix.version();
}

When I worked in a dev environment, everything was fine. Now, after rolling out to production and building with npm run production, assets are sometimes loaded incorrectly. For example, you can go to https://ozzgame.com and poke the top menu. At some point, always randomly, a message will appear in the console:
SyntaxError: expected expression, got '<'
By clicking "details", you can see that the browser is trying to load the relative path, not root:
view-source:https://ozzgame.com/history/assets/js/coinflip-bundle.a8143c8e6e217b6de272.js

Why is this happening? How to fix it? The strangest thing is that it always happens in different places.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2017-08-14
@Alex_Wells

JS uses dynamic loading, and non-absolute paths are used there, so everything breaks when there is a "subfolder" in the address, i.e. site.com/dsa/sada

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question