For a project built locally using Vue-cli, the webpack configuration has not been touched and it runs without any problems locally. However, I plan to put it on the Nginx server. Do I need to change any configuration? Then how to deploy Nginx?
I searched, and some said to change assetsPublicPath in index.js under config: './' (/a/11...)
Some say to add publicPath:'./' (http://blog.csdn.net/gebitan5...) to the output of webpack.prod.conf.js
After trying everything, it still can’t be opened on the server, please help~~~~
If it is just Vue, package it through
npm run build
, and then publish the static files in the dist to the server. In the Nginx configuration, configure the folder pointing to the static files through thelocation
path, which will directly access the file. The index.html file in the folder...If you want to access your built project directly through the domain name, such as hzzly.net, then change assetsPublicPath: '/' in index.js under config. No need to change. If you want to add another layer after the domain name, such as hzzly.net /resume, then change the index.js under config to assetsPublicPath: '/resume/', the following nginx configuration can remain unchanged, just create a new resume folder directly in the main directory of the website.
Load the homepage, view the HTML file, and check whether the resource reference path is correct.
Similar to the picture above, check the path in src to see if the resources in your server are correct. If it is incorrect, go to webpack to modify the resource packaging path.
Is it 404 when accessing js?