Vue+Webpack 部署到 FC

http://vue.demo.q123q.cc/aboutopen in new window

添加依赖

{
  "devDependencies": {
    "@midwayjs/cli": "^1.2.36"
    ...
  },
  "scripts": {
    "deploy": "npm run build && midway-bin deploy --skipBuild"
  }
}
1
2
3
4
5
6
7
8
9

编写配置

// vue.config.js
module.exports = {
  assetsDir: "static",
};
1
2
3
4

f.yaml

deployType:
  type: static
  config:
    rootDir: dist ## 托管目录变为 dist
    notFoundUrl: /index.html # 404 页面
    rewrite:
      - "/(.*)": /index.html
      - "@not /static/(.*)": /index.html

package:
  include:
    - dist
1
2
3
4
5
6
7
8
9
10
11
12

实测 ,notFoundUrlrewrite 一个都不能少。

但是效果很不好,多次请求,会 404 。。。

能用,效果不行。

但是能用就很好了。