Skip to content

Commit e929d48

Browse files
committed
fix: fix cypress error caused by object rest syntax
1 parent 4cabf5e commit e929d48

File tree

1 file changed

+21
-9
lines changed
  • packages/@vue/cli-service/lib/config

1 file changed

+21
-9
lines changed

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

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,27 @@ module.exports = (api, options) => {
177177
const normalizePageConfig = c => typeof c === 'string' ? { entry: c } : c
178178

179179
pages.forEach(name => {
180+
const pageConfig = normalizePageConfig(multiPageConfig[name])
180181
const {
181-
title,
182182
entry,
183183
template = `public/${name}.html`,
184184
filename = `${name}.html`,
185-
chunks,
186-
...customHtmlOptions
187-
} = normalizePageConfig(multiPageConfig[name])
185+
chunks = ['chunk-vendors', 'chunk-common', name]
186+
} = pageConfig
187+
188+
// Currently Cypress v3.1.0 comes with a very old version of Node,
189+
// which does not support object rest syntax.
190+
// (https://github.com/cypress-io/cypress/issues/2253)
191+
// So here we have to extract the customHtmlOptions manually.
192+
const customHtmlOptions = {}
193+
for (const key in pageConfig) {
194+
if (
195+
!['entry', 'template', 'filename', 'chunks'].includes(key)
196+
) {
197+
customHtmlOptions[key] = pageConfig[key]
198+
}
199+
}
200+
188201
// inject entry
189202
webpackConfig.entry(name).add(api.resolve(entry))
190203

@@ -202,14 +215,13 @@ module.exports = (api, options) => {
202215
// inject html plugin for the page
203216
const pageHtmlOptions = Object.assign(
204217
{},
218+
customHtmlOptions,
205219
htmlOptions,
206220
{
207-
chunks: chunks || ['chunk-vendors', 'chunk-common', name],
221+
chunks,
208222
template: templatePath,
209-
filename: ensureRelative(outputDir, filename),
210-
title
211-
},
212-
customHtmlOptions
223+
filename: ensureRelative(outputDir, filename)
224+
}
213225
)
214226

215227
webpackConfig

0 commit comments

Comments
 (0)