Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: indexPath should also affect non-production builds (#2327) #4057

Merged
merged 1 commit into from Jul 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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