[solved] how webpack automatically compiles and packages vui-cli projects

Business background

  • develop Wechat official account through vue-cli webpack template
  • because to call the official account API, you must configure the request domain name url , such as example.com .
  • and this domain name must be configured in the official account backend legitimate business domain name
  • when I do not adjust the Wechat interface, I can test it through localhost .
  • but when it comes to api such as WeChat Pay or Wechat Map , you must upload the code to example.com for testing
  • .

problem description

  • this is very troublesome. Every time you modify the code and need to be tested, you must go through the following steps

    1. modify the code
    2. compile the package file npm run build
    3. upload packaged files to the server via ftp

question

  • is there any way to make npm run build execute automatically
  • means to package files automatically when they change, similar to npm run dev
  • .
  • it"s even better to upload ftp automatically after compilation
  • .

my attempt

  • probably knows that you want to set watch
  • but I haven"t configured the webpack file, so I haven"t worked it out for half an hour. Let"s ask a question
  • .
Apr.03,2021

you can use proxy to forward localhost/api/ to example.com/
proxyTable of devServer can be configured in development environment
forwarding rules of nginx, tomcat and other servers can be configured in formal environment


this is not clear in one sentence or two, and it is difficult for me to understand your project more clearly. Let me give you some advice.

for ftp upload, please refer to what I wrote: https://github.com/azl3979858.

.

for automation, please refer to what I wrote: https://github.com/azl3979858.

.
Menu