improve plugin imports

This commit is contained in:
Pooya Parsa 2017-12-07 13:27:07 +03:30
parent 652c3d63d1
commit 67f04458ec
2 changed files with 5 additions and 6 deletions

View File

@ -12,9 +12,8 @@ import { setContext, getLocation, getRouteData } from './utils'
<% if (store) { %>import { createStore } from './store.js'<% } %> <% if (store) { %>import { createStore } from './store.js'<% } %>
/* Plugins */ /* Plugins */
<% plugins.forEach(plugin => { %>import <%= plugin.name %> from '<%= plugin.name %>' // Source: <%= relativeToBuild(plugin.src) %><%= (plugin.ssr===false) ? ' (ssr: false)' : '' %>
<% plugins.forEach(plugin => { %>// <%= plugin.src %><%= (plugin.ssr===false) ? ' (Only included in client bundle)' : '' %> <% }) %>
import <%= plugin.name %> from '<%= plugin.name %>'<% }) %>
// Component: <no-ssr> // Component: <no-ssr>
Vue.component(NoSSR.name, NoSSR) Vue.component(NoSSR.name, NoSSR)

View File

@ -69,14 +69,14 @@ export default class Builder {
} }
get plugins() { get plugins() {
return this.options.plugins.map((p, i) => { return _.uniqBy(this.options.plugins.map((p, i) => {
if (typeof p === 'string') p = { src: p } if (typeof p === 'string') p = { src: p }
return { return {
src: this.nuxt.resolvePath(p.src), src: this.nuxt.resolvePath(p.src),
ssr: (p.ssr !== false), ssr: (p.ssr !== false),
name: basename(p.src, extname(p.src)).replace(/[^a-zA-Z?\d\s:]/g, '') + '_plugin_' + hash(p.src) name: basename(p.src, extname(p.src)).replace(/[^a-zA-Z?\d\s:]/g, '') + '_' + hash(p.src)
} }
}) }), p => p.name)
} }
vendor() { vendor() {