D
D
Denis Bondarenko2019-11-21 12:40:28
Vue.js
Denis Bondarenko, 2019-11-21 12:40:28

Vue-CLI is not generating assets correctly when building on the server, what could be the problem?

You need to publish the Vue-CLI project to servername/admin .
I create vue.config.js:

module.exports = {
  publicPath: process.env.NODE_ENV === 'production' ? '/admin/' : '/',
};

On localhost, npm run serveeverything works as usual.
But on the server after the build at the above address there is an empty page.
We look at the errors:
5dd65b324ce21210462067.png
We go, for example, to chunk-vendors.53bf2074.js , and there is the content of index.html :
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><title>Admin</title><link href=/admin/css/app.600a3af1.css rel=preload as=style><link href=/admin/css/chunk-vendors.18c93001.css rel=preload as=style><link href=/admin/js/app.33da4755.js rel=preload as=script><link href=/admin/js/chunk-vendors.53bf2074.js rel=preload as=script><link href=/admin/css/chunk-vendors.18c93001.css rel=stylesheet><link href=/admin/css/app.600a3af1.css rel=stylesheet></head>...

In other files, it is the same as in .js, in .css.
And I don’t even quite understand where to dig: either the webpack settings are incorrect and they need to be changed in vue.config.js, or the server builds wrong, or the asset files need to be moved.
What could be the problem?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question