Configuration Reference
Global CLI Config
Some global configurations for @vue/cli, such as your preferred package manager and your locally saved presets, are stored in a JSON file named .vuerc in your home directory. You can edit this file directly with your editor of choice to change the saved options.
You can also use the vue config command to inspect or modify the global CLI config.
Target Browsers
See the Browser Compatibility section in guide.
vue.config.js
vue.config.js is an optional config file that will be automatically loaded by @vue/cli-service if it's present in your project root (next to package.json). You can also use the vue field in package.json, but do note in that case you will be limited to JSON-compatible values only.
The file should export an object containing options:
// vue.config.js
/**
* @type {import('@vue/cli-service').ProjectOptions}
*/
module.exports = {
// options...
}
Or, you can use the defineConfig helper from @vue/cli-service, which could provide better intellisense support:
// vue.config.js
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
// options...
})
baseUrl
Deprecated since Vue CLI 3.3, please use publicPath instead.
publicPath
Type:
stringDefault:
'/'The base URL your application bundle will be deployed at (known as
baseUrlbefore Vue CLI 3.3). This is the equivalent of webpack'soutput.publicPath, but Vue CLI also needs this value for other purposes, so you should always usepublicPathinstead of modifying webpackoutput.publicPath.By default, Vue CLI assumes your app will be deployed at the root of a domain, e.g.
https://www.my-app.com/. If your app is deployed at a sub-path, you will need to specify that sub-path using this option. For example, if your app is deployed athttps://www.foobar.com/my-app/, setpublicPathto'/my-app/'.The value can also be set to an empty string (
'') or a relative path (./) so that all assets are linked using relative paths. This allows the built bundle to be deployed under any public path, or used in a file system based environment like a Cordova hybrid app.Limitations of relative publicPath
Relative
publicPathhas some limitations and should be avoided when:You are using HTML5
history.pushStaterouting;You are using the
pagesoption to build a multi-paged app.
This value is also respected during development. If you want your dev server to be served at root instead, you can use a conditional value:
module.exports = { publicPath: process.env.NODE_ENV === 'production' ? '/production-sub-path/' : '/' }
outputDir
Type:
stringDefault:
'dist'The directory where the production build files will be generated in when running
vue-cli-service build. Note the target directory contents will be removed before building (this behavior can be disabled by passing--no-cleanwhen building).TIP
Always use
outputDirinstead of modifying webpackoutput.path.