Skip to content

feat: support multi-main entry in pages config #3595

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

Merged
merged 1 commit into from
Apr 1, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/@vue/cli-service/__tests__/multiPage.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async function makeProjectMultiPage (project) {
index: { entry: 'src/main.js' },
foo: { entry: 'src/foo.js' },
bar: { entry: 'src/bar.js' },
foobar: { entry: 'src/foobar.js' }
foobar: { entry: ['src/foobar.js'] }
},
chainWebpack: config => {
const splitOptions = config.optimization.get('splitChunks')
Expand Down
3 changes: 2 additions & 1 deletion packages/@vue/cli-service/lib/config/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ module.exports = (api, options) => {
}

// inject entry
webpackConfig.entry(name).add(api.resolve(entry))
const entries = Array.isArray(entry) ? entry : [entry]
webpackConfig.entry(name).merge(entries.map(e => api.resolve(e)))

// resolve page index template
const hasDedicatedTemplate = fs.existsSync(api.resolve(template))
Expand Down
9 changes: 7 additions & 2 deletions packages/@vue/cli-service/lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ const schema = createSchema(joi => joi.object({
pages: joi.object().pattern(
/\w+/,
joi.alternatives().try([
joi.string(),
joi.string().required(),
joi.array().items(joi.string().required()),

joi.object().keys({
entry: joi.string().required()
entry: joi.alternatives().try([
joi.string().required(),
joi.array().items(joi.string().required())
]).required()
}).unknown(true)
])
),
Expand Down