我想重新命名由npm run build命名的index.html.我在网页配置中找不到任何东西.

我还创建了这里描述的vue.config.js:https://github.com/vuejs/vue-cli/tree/dev/docs/config

module.exports = {
  pages: {
    index: {
      filename: 'dapp.html',
    }
  }
};

但输出文件仍然是index.html

推荐答案

因为您正在创建vue.配置.我假设您使用的是vue cli 3.0.

鉴于此,您应该在vue上添加以下行.配置.js.

module.exports = {
    // modify the location of the generated HTML file.
    // make sure to do this only in production.
    chainWebpack: (config) => {
        if (process.env.NODE_ENV === 'production') {
            config.plugin('html').tap((opts) => {
                opts[0].filename = './dist/dapp.html';
                return opts;
            });
        }
     },
};

Vue的创建者在github https://github.com/yyx990803/laravel-vue-cli-3上设置了一个laravel-Vue-cli-3示例,您可以在其中查看

更新vue cli的早期版本

如果您使用的是vue webpack模板,那么在config文件夹中有一个索引.js文件.舱内.导出您可以在以下位置设置输出:

...
build: {
    // Template for index.html
    index: path.resolve(__dirname, './dist/index.html'),

    ...
},

只需更改索引.html和dapp.html,这应该是可行的.

如果你使用的是网页模板,你可以在http://vuejs-templates.github.io/webpack/backend.html页看到更多细节.

Vue.js相关问答推荐

我可以手动访问 vue-router 解析器吗?

Vue.js 3 没有组件的实例?

v-model 修饰符返回空

为什么 Vue 在将设置脚本中的计算(computed)属性渲染到模板时找不到变量

视图中的 vue 样式不适用于 html

如何使用 Vite 从公共目录导入 JSON 文件?

VueJS CKeditor5 上传图片

在 Vue 中启用(控制台)记录路由事件

理解 VueJS 中的组件 props

如何在 Vue.js 中触发点击 ref

如何将 Nuxt.js 更新到最新版本

重新加载发布到 Github 页面的 Vue 网站时出现 404

Vue.js:TypeError:无法设置只有 getter 的 # 的属性props

Vue.js 处理多次点击事件

在找不到图像源时设置替代图像

Leaflet+Vue+Vuetify / Leaflet map 隐藏 vuetify 弹出对话框

在 nuxt.js 页面中包含外部 javascript 文件

Vue 2.0 设置路由 - 不要使用new来产生副作用

带有 Firebase 云消息传递的 Vue pwa 无法正常工作

使用 vue.js 获取调用元素