首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >每页Vuejs MPA和indexPath

每页Vuejs MPA和indexPath
EN

Stack Overflow用户
提问于 2020-09-09 17:42:58
回答 1查看 368关注 0票数 1

vue.config.js中,可以使用indexPath设置index.html的输出位置和文件名。

例如vue.config.js

代码语言:javascript
复制
module.exports = {
    indexPath: "../backend/api/templates/base.html"
}

index.html文件输出到名为"base.html"backend/api/templates

我想要建立一个MPA,其中产生了几个html。

via:

代码语言:javascript
复制
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 输出到具有特定名称的特定文件夹中。可以吗?

EN

回答 1

Stack Overflow用户

发布于 2020-09-09 20:35:01

为了子孙后代-多亏了沃德土地上的矛盾:

filename字段可以包含相对于outputDir的路径。

代码语言:javascript
复制
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",

产出:

代码语言:javascript
复制
backend
|---api
    |---static
    |   |--- dist
    |   |      payload of js, css, img etc
    |---templates
        |--- base-vue.html
        |--- base-vue-about.html
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63816863

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档