Packaging and local preview

Construction of packaging

Before you publish on-line, we need to do to build package, the .less, .vue, .jsand other related resources compiler package, the browser can be directly converted into common identification run css, js, html.

// 打包
# yarn run build 或者 yarn build
npm run build

每次 `npm run build` 都会先把原来的 dist 删除,然后生成新的结果。

VueCLIWill generate a packed result is stored in the project distdirectory.

Packaging disabled hash value;

Set in vue.config.js the filenameHashingoption;

module.exports = {
  // webpack配置: 关闭哈希值
  filenameHashing: false
}

Preview packed result

Note : You can not double-click to open the index.html run.

The dist into a Web server running the test, a common Web server:

  • Ngxin
  • Apache
  • tomcat
  • IIS
  • Node.js

Recommended Vueofficial recommended a command-line httpservice tool: serve .

distDirectory need to start an HTTP server to access, so the file://agreement directly open dist/index.htmlwill not work. Node.js is to use a static file server in the easiest way to preview the local production environment to build, for example, serve :

installation:

# yarn global add serve
# 安装全局包,在任何目录执行都可以
npm install -g serve
或
npm install serve

Then executed in your project directory:

# dist 是运行 Web 服务根目录
serve -s dist
或 注意 两者有区别
serve dist

If the startup is successful, you will see the following prompt:

   ┌────────────────────────────────────────────────────┐
   │                                                    │
   │   Serving!                                         │
   │                                                    │
   │   - Local:            http://localhost:5000        │
   │   - On Your Network:  http://192.168.156.90:5000   │
   │                                                    │
   │   Copied local address to clipboard!               │
   │                                                    │
   └────────────────────────────────────────────────────┘

serve occupancy default port 5000 and start a service

deploy

  • The company has specialized devops, is the operation and maintenance
    • Some companies no specific operation and maintenance personnel, it is responsible for the back-end
# --force 强制推送,简写 -f
git push -u origin master -f

Guess you like

Origin www.cnblogs.com/ywnh/p/12354109.html