Home  >  Q&A  >  body text

javascript - How to deploy files generated by npm run build to the server

I am new to the front-end and wrote a front-end project using vue-cli scaffolding. It is currently known to use npm run dev for local debugging on port 8080, but this is limited to debugging. So how to publish it after npm run build generates the dist folder? Some people say just drop the dist folder on the server.
Then the question comes:

Xiaobai seeks popular science~Any relevant articles, information, and project links can be sent to me, thank you in advance~

大家讲道理大家讲道理2663 days ago1334

reply all(4)I'll reply

  • 某草草

    某草草2017-07-05 11:03:32

    First of all, let’s talk about the server. In fact, it is almost the same as your computer. There are some differences. The server may have better hardware conditions than your computer. Then, some servers remove the graphical interface layer for operating efficiency. So for your question, you only need to configure the environment on the server, and then put the project on the server. The same operation as on your computer. How you run the project locally can also be run on the server. Maybe it is not suitable for people who don’t have For the graphical interface, you need to use the command line or terminal, and then configure your server domain name and run it to access it.

    reply
    0
  • 女神的闺蜜爱上我

    女神的闺蜜爱上我2017-07-05 11:03:32

    Well, I tried using IIS and the environment officially provided by the server to host my website. Generally speaking, if you just put a static page, you only need to learn how to configure IIS, and then put your page in the directory you specify. Note that the security groups of some servers will hinder your access. If you are not afraid of others, Hacker opened all security groups on the server. Secondly, when reinstalling the Tencent Cloud server class, you can go to the public market to select an environment. For my PHP project, I used an environment created by others. I uploaded the project directly and built a database.

    reply
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-07-05 11:03:32

    I just saw this question node.js - I don’t understand res.sendFile(path.resolve('./public'))

    You used the npm command. I think you should also have some understanding of node.js. You can use express to set up a server, and then replace public with your dist directory like in the question above. I don’t know this. If you want to practice, give it a try.

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-07-05 11:03:32

    Actually, the answers from the two people above are both correct, but the emphasis is different. The first floor is from a big perspective, just configure the server and run it as you want, but no one has ever deployed the project. Maybe you don’t know what’s going on; the second floor should be talking about the environment for configuring the windos server. If you haven’t used it before, you probably don’t understand what’s going on;
    Actually, since you know that you use npm run build to generate the file, Then you should also see that the generated files are js, css and html files. In other words, no matter what system the server is, as long as your server has server software that supports http or https, I know of nginx and apache. Just install one of the two, and match the access path, put the file you generated under the server or mapping path, start your server software, and then you can use the path you configured to access the project. So you need to understand two things:
    1. How to install nginx or apache. There are many articles about this on Baidu.
    2. How to configure nginx or apache. There are also many articles on Baidu.

    Once you understand these two projects, they will be ready

    Why don’t I explain how to install and configure it here? This is not something that can be explained clearly in one or two sentences. I can’t describe it clearly;

    reply
    0
  • Cancelreply