fix(builder): corretly detect mode of hashed plugins (#5695)

This commit is contained in:
Pooya Parsa 2019-05-11 13:53:37 +04:30 committed by GitHub
parent 28d9d46fa4
commit 67750245ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -256,7 +256,7 @@ export default class Builder {
normalizePlugins() { normalizePlugins() {
const modes = ['client', 'server'] const modes = ['client', 'server']
const modePattern = new RegExp(`\\.(${modes.join('|')})(\\.\\w+)?$`) const modePattern = new RegExp(`\\.(${modes.join('|')})(\\.\\w+)*$`)
return uniqBy( return uniqBy(
this.options.plugins.map((p) => { this.options.plugins.map((p) => {
if (typeof p === 'string') { if (typeof p === 'string') {

View File

@ -20,6 +20,7 @@ describe('builder: builder plugins', () => {
const nuxt = createNuxt() const nuxt = createNuxt()
nuxt.options.plugins = [ nuxt.options.plugins = [
'/var/nuxt/plugins/test.js', '/var/nuxt/plugins/test.js',
'/var/nuxt/.nuxt/foo-bar.plugin.client.530b6c6a.js',
{ src: '/var/nuxt/plugins/test.server', mode: 'server' }, { src: '/var/nuxt/plugins/test.server', mode: 'server' },
{ src: '/var/nuxt/plugins/test.client', ssr: false } { src: '/var/nuxt/plugins/test.client', ssr: false }
] ]
@ -33,6 +34,11 @@ describe('builder: builder plugins', () => {
name: 'nuxt_plugin_test_hash(/var/nuxt/plugins/test.js)', name: 'nuxt_plugin_test_hash(/var/nuxt/plugins/test.js)',
src: 'resolveAlias(/var/nuxt/plugins/test.js)' src: 'resolveAlias(/var/nuxt/plugins/test.js)'
}, },
{
mode: 'client',
name: 'nuxt_plugin_foobarpluginclient530b6c6a_hash(/var/nuxt/.nuxt/foo-bar.plugin.client.530b6c6a.js)',
src: 'resolveAlias(/var/nuxt/.nuxt/foo-bar.plugin.client.530b6c6a.js)'
},
{ {
mode: 'server', mode: 'server',
name: 'nuxt_plugin_test_hash(/var/nuxt/plugins/test.server)', name: 'nuxt_plugin_test_hash(/var/nuxt/plugins/test.server)',