Skip to content

Commit 9faddce

Browse files
shadow-lighthaoqunjiang
authored andcommitted
fix: indexPath should also affect non-production builds (#4057)
fixes #2327 fixes #4247
1 parent 52ae1c8 commit 9faddce

File tree

2 files changed

+19
-22
lines changed

2 files changed

+19
-22
lines changed

packages/@vue/cli-service/lib/commands/build/index.js

+6-9
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,12 @@ async function build (args, api, options) {
123123
}
124124
}
125125

126-
const targetDir = api.resolve(args.dest || options.outputDir)
126+
if (args.dest) {
127+
// Override outputDir before resolving webpack config as config relies on it (#2327)
128+
options.outputDir = args.dest
129+
}
130+
131+
const targetDir = api.resolve(options.outputDir)
127132
const isLegacyBuild = args.target === 'app' && args.modern && !args.modernBuild
128133

129134
// resolve raw webpack config
@@ -142,14 +147,6 @@ async function build (args, api, options) {
142147
// check for common config errors
143148
validateWebpackConfig(webpackConfig, api, options, args.target)
144149

145-
// apply inline dest path after user configureWebpack hooks
146-
// so it takes higher priority
147-
if (args.dest) {
148-
modifyConfig(webpackConfig, config => {
149-
config.output.path = targetDir
150-
})
151-
}
152-
153150
if (args.watch) {
154151
modifyConfig(webpackConfig, config => {
155152
config.watch = true

packages/@vue/cli-service/lib/config/app.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,20 @@ module.exports = (api, options) => {
9292
}
9393
}
9494

95-
if (isProd) {
96-
// handle indexPath
97-
if (options.indexPath !== 'index.html') {
98-
// why not set filename for html-webpack-plugin?
99-
// 1. It cannot handle absolute paths
100-
// 2. Relative paths causes incorrect SW manifest to be generated (#2007)
101-
webpackConfig
102-
.plugin('move-index')
103-
.use(require('../webpack/MovePlugin'), [
104-
path.resolve(outputDir, 'index.html'),
105-
path.resolve(outputDir, options.indexPath)
106-
])
107-
}
95+
// handle indexPath
96+
if (options.indexPath !== 'index.html') {
97+
// why not set filename for html-webpack-plugin?
98+
// 1. It cannot handle absolute paths
99+
// 2. Relative paths causes incorrect SW manifest to be generated (#2007)
100+
webpackConfig
101+
.plugin('move-index')
102+
.use(require('../webpack/MovePlugin'), [
103+
path.resolve(outputDir, 'index.html'),
104+
path.resolve(outputDir, options.indexPath)
105+
])
106+
}
108107

108+
if (isProd) {
109109
Object.assign(htmlOptions, {
110110
minify: {
111111
removeComments: true,

0 commit comments

Comments
 (0)