{"record":{"id":"09c447a19d76f59d","repo":"vuejs/vue-cli","slug":"configuration-error-avoid-modifying-webpack-out-09c447","errorCode":null,"errorMessage":"\n\nConfiguration Error: Avoid modifying webpack output.publicPath directly. Use the \"publicPath\" option instead.\n","messagePattern":"\n\nConfiguration Error: Avoid modifying webpack output\\.publicPath directly\\. Use the \"publicPath\" option instead\\.\n","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@vue/cli-service/lib/util/validateWebpackConfig.js","lineNumber":32,"sourceCode":"    // user directly modifies output.path in configureWebpack or chainWebpack.\n    // this is not supported because there's no way for us to give copy\n    // plugin the correct value this way.\n    throw new Error(\n      `\\n\\nConfiguration Error: ` +\n      `Avoid modifying webpack output.path directly. ` +\n      `Use the \"outputDir\" option instead.\\n`\n    )\n  }\n\n  if (actualTargetDir === api.service.context) {\n    throw new Error(\n      `\\n\\nConfiguration Error: ` +\n      `Do not set output directory to project root.\\n`\n    )\n  }\n\n  if (target === 'app' && singleConfig.output.publicPath !== options.publicPath) {\n    throw new Error(\n      `\\n\\nConfiguration Error: ` +\n      `Avoid modifying webpack output.publicPath directly. ` +\n      `Use the \"publicPath\" option instead.\\n`\n    )\n  }\n}\n","sourceCodeStart":14,"sourceCodeEnd":39,"githubUrl":"https://github.com/vuejs/vue-cli/blob/7eb93c169c7520935252e2473387f923ef80d856/packages/@vue/cli-service/lib/util/validateWebpackConfig.js#L14-L39","documentation":"For the 'app' build target, validateWebpackConfig ensures webpack's `output.publicPath` still equals the configured `publicPath` option. A direct mutation in configureWebpack/chainWebpack is rejected because it bypasses the option system that other plugins depend on.","triggerScenarios":"In a webpack hook setting `config.output.publicPath = '/'` (or any value) for an app build.","commonSituations":"Copy-pasted webpack config that sets publicPath; plugins that override publicPath unconditionally.","solutions":["Set `publicPath` in vue.config.js instead.","Remove the `config.output.publicPath = ...` line from your webpack hooks."],"exampleFix":"// vue.config.js — before (in chainWebpack)\nconfig.output.publicPath = '/app/'\n// after\nmodule.exports = { publicPath: '/app/' }","handlingStrategy":"validation","validationCode":"// inside your webpack hook — never mutate; assert equality\nif (config.output.publicPath !== options.publicPath) {\n  throw new Error('Refusing to mutate output.publicPath; set the publicPath option instead')\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat output.publicPath as read-only in chainWebpack/configureWebpack.","Set base URL via the publicPath option in vue.config.js."],"tags":["webpack","configuration","public-path"],"backgroundTag":null,"analyzedSha":"7eb93c169c7520935252e2473387f923ef80d856","analyzedAt":"2026-08-13T10:13:37.803Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}