说明
vue.config.js 可以修改工程中的一些配置,如下:
详见官网:https://cli.vuejs.org/zh/config/#vue-config-js
所在位置
在工程中,默认没有该文件,此时表示 使用默认配置
如果需要修改配置,要 手动创建
在工程根目录下创建文件:vue.config.js,与 package.json 文件同级目录,如下:
什么时候读取该文件
如果该文件存在,当执行 npm run serve 命令时会自动加载
例子
修改 index.html 的 <title>,如下图:
代码
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
pages: {
index: {
// page 的入口,必须写,否则报错
entry: 'src/main.js',
// 当使用 title 选项时,
// template 中的 title 标签需要是 <title><%= htmlWebpackPlugin.options.title %></title>
title: '测试标题',
},
}
})

