vue.js - 每页的 Vuejs MPA 和 indexPath
问题描述
in - 可以设置使用vue.config.js
的输出位置和文件名index.html
indexPath
例如vue.config.js
module.exports = {
indexPath: "../backend/api/templates/base.html"
}
将index.html
文件输出到backend/api/templates
named "base.html"
。
我想构建一个生成多个 html 的 MPA。
通过:
module.exports = {
pages: {
index: {
entry: "./src/pages/home/main.ts",
template: "public/index.html",
filename: "index.html",
chunks: ["chunk-vendors", "index"]
},
about: {
entry: "./src/pages/about/main.ts",
template: "public/index.html",
filename: "about.html",
chunks: ["chunk-vendors", "about"]
}
},
outputDir: "backend/api/static/dist",
assetsDir: "static",
indexPath: "../backend/api/templates/base-vue.html",
...
但是我只能index.html
重命名为base-vue.html
.
我希望能够将about.html
输出输出到具有特定名称的特定文件夹中。
这可能吗?
解决方案
为了后代 - 感谢 Vue Land discord 上的 wrksx:
该filename
字段可以包含相对于outputDir
module.exports = {
pages: {
index: {
entry: "./src/pages/home/main.ts",
template: "public/index.html",
filename: "../../templates/base-vue.html",
chunks: ["chunk-vendors", "index"]
},
about: {
entry: "./src/pages/about/main.ts",
template: "public/index.html",
filename: "../../templates/base-vue-about.html",
chunks: ["chunk-vendors", "about"]
}
},
outputDir: "backend/api/static/dist",
// not needed assetsDir: "static",
// not needed indexPath: "../backend/api/templates/base-vue.html",
输出:
backend
|---api
|---static
| |--- dist
| | payload of js, css, img etc
|---templates
|--- base-vue.html
|--- base-vue-about.html
推荐阅读
- javascript - 我只放了一个入口点,但是很多文件在 webpack 中编译
- octave - Octave - 带有 lsode 的微分方程组
- flutter - TextField Flutter 中的 Minlines 或类似内容
- android - 我放了一些广告和 AdMob 代码,但无法观看
- javascript - 在调用了所有脚本之后,如何获取页面的 html 源代码?
- javascript - React componentWillUpdate 被调用两次
- hadoop - 格式化本地文件系统 HDFS 并启动 Hadoop
- delphi - TJclStringList 在 Free 上崩溃
- android - 从 iOS 和 Android 打印 html 模板
- javascript - 取消订阅以 Angular 6 停止上传进度但不是实际上传