From 7c580b8f0bcd7bfc9905976a883c1405ad563c1c Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Wed, 10 Mar 2021 13:28:33 +0800 Subject: [PATCH] fix: fix `build --dest` option (#6314) Closes #6312 --- packages/@vue/cli-service/__tests__/build.spec.js | 14 ++++++++++++++ .../lib/commands/build/resolveAppConfig.js | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/@vue/cli-service/__tests__/build.spec.js b/packages/@vue/cli-service/__tests__/build.spec.js index 8ebd58e65a..c32e8bffa8 100644 --- a/packages/@vue/cli-service/__tests__/build.spec.js +++ b/packages/@vue/cli-service/__tests__/build.spec.js @@ -91,6 +91,20 @@ test('build with --report-json', async () => { expect(appChunk).toHaveProperty('modules') }) +test('build with --dest', async () => { + const project = await create('e2e-build-dest', defaultPreset) + + const { stdout } = await project.run('vue-cli-service build --dest other_dist') + expect(stdout).toMatch('Build complete.') + + expect(project.has('other_dist/index.html')).toBe(true) + expect(project.has('other_dist/favicon.ico')).toBe(true) + expect(project.has('other_dist/js')).toBe(true) + expect(project.has('other_dist/css')).toBe(true) + + expect(project.has('dist')).toBe(false) +}) + afterAll(async () => { if (browser) { await browser.close() diff --git a/packages/@vue/cli-service/lib/commands/build/resolveAppConfig.js b/packages/@vue/cli-service/lib/commands/build/resolveAppConfig.js index 564482cf40..d073f6ddd6 100644 --- a/packages/@vue/cli-service/lib/commands/build/resolveAppConfig.js +++ b/packages/@vue/cli-service/lib/commands/build/resolveAppConfig.js @@ -12,7 +12,7 @@ module.exports = (api, args, options) => { // respect inline build destination in copy plugin if (args.dest && config.plugins.has('copy')) { config.plugin('copy').tap(pluginArgs => { - pluginArgs[0][0].to = targetDir + pluginArgs[0].patterns.to = targetDir return pluginArgs }) }