Webpack - a project written by vue-cli (no problem running locally), is going to be put on the Nginx server. What configuration needs to be changed? How else to deploy?
高洛峰
高洛峰 2017-05-27 17:44:57
0
4
1127

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~~~~

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(4)
巴扎黑

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 the location 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.

server {
        listen       80;
        server_name  localhost;

        location / {
            root   /home/hzzly;  //这里配置网站主目录
            index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
左手右手慢动作

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.

Ty80

Is it 404 when accessing js?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template