Skip to content

Commit

Permalink
fix: indexPath should also affect non-production builds (#2327)
Browse files Browse the repository at this point in the history
  • Loading branch information
shadow-light committed May 24, 2019
1 parent 197fd92 commit 1a76155
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 22 deletions.
15 changes: 6 additions & 9 deletions packages/@vue/cli-service/lib/commands/build/index.js
Expand Up @@ -123,7 +123,12 @@ async function build (args, api, options) {
}
}

const targetDir = api.resolve(args.dest || options.outputDir)
if (args.dest) {
// Override outputDir before resolving webpack config as config relies on it (#2327)
options.outputDir = args.dest
}

const targetDir = api.resolve(options.outputDir)
const isLegacyBuild = args.target === 'app' && args.modern && !args.modernBuild

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

// apply inline dest path after user configureWebpack hooks
// so it takes higher priority
if (args.dest) {
modifyConfig(webpackConfig, config => {
config.output.path = targetDir
})
}

if (args.watch) {
modifyConfig(webpackConfig, config => {
config.watch = true
Expand Down
26 changes: 13 additions & 13 deletions packages/@vue/cli-service/lib/config/app.js
Expand Up @@ -92,20 +92,20 @@ module.exports = (api, options) => {
}
}

if (isProd) {
// handle indexPath
if (options.indexPath !== 'index.html') {
// why not set filename for html-webpack-plugin?
// 1. It cannot handle absolute paths
// 2. Relative paths causes incorrect SW manifest to be generated (#2007)
webpackConfig
.plugin('move-index')
.use(require('../webpack/MovePlugin'), [
path.resolve(outputDir, 'index.html'),
path.resolve(outputDir, options.indexPath)
])
}
// handle indexPath
if (options.indexPath !== 'index.html') {
// why not set filename for html-webpack-plugin?
// 1. It cannot handle absolute paths
// 2. Relative paths causes incorrect SW manifest to be generated (#2007)
webpackConfig
.plugin('move-index')
.use(require('../webpack/MovePlugin'), [
path.resolve(outputDir, 'index.html'),
path.resolve(outputDir, options.indexPath)
])
}

if (isProd) {
Object.assign(htmlOptions, {
minify: {
removeComments: true,
Expand Down

0 comments on commit 1a76155

Please sign in to comment.