I am using dynamic imports for lazy loading Vue routes. On development, everything works but dynamic imports break in build and relative paths are used for chunks instead of absolute paths.
Adding __webpack_public_path__ = '/' on top of main.js, fixed vue routing (opening routes from main page). But when some page /users/all is opened directly, the chunk files are fetched from wrong url. I have also tried adding webpack-require-from plugin, but didn't help in my case.
Expect Url for chunks: website.com/dist/js/[name].[chunkhash].js
Webpack appends like this: website.com/users/dist/js/[name].[chunkhash].js website.com/users/userid/profile/dist/js/[name].[chunkhash].js website.com/users/dist/css/[name].[chunkhash].js
I am using dynamic imports for lazy loading Vue routes. On development, everything works but dynamic imports break in
build
and relative paths are used for chunks instead of absolute paths.Adding
__webpack_public_path__ = '/'
on top ofmain.js
, fixed vue routing (opening routes from main page). But when some page/users/all
is opened directly, the chunk files are fetched from wrong url. I have also tried adding webpack-require-from plugin, but didn't help in my case.Expect Url for chunks:
website.com/dist/js/[name].[chunkhash].js
Webpack appends like this:
website.com/users/dist/js/[name].[chunkhash].js
website.com/users/userid/profile/dist/js/[name].[chunkhash].js
website.com/users/dist/css/[name].[chunkhash].js
webpack.base.conf.js
webpack.prod.conf.js