Add webpackChunkName

This commit is contained in:
Sébastien Chopin 2017-04-17 18:15:37 +02:00
parent 6886f8bd57
commit 2eecb8c0de
2 changed files with 3 additions and 3 deletions

View File

@ -12,7 +12,7 @@ let layouts = {
<% <%
var layoutsKeys = Object.keys(layouts); var layoutsKeys = Object.keys(layouts);
layoutsKeys.forEach(function (key, i) { %> layoutsKeys.forEach(function (key, i) { %>
"_<%= key %>": () => import('<%= layouts[key] %>')<%= (i + 1) < layoutsKeys.length ? ',' : '' %> "_<%= key %>": () => import('<%= layouts[key] %>' /* webpackChunkName: "layouts/<%= key %>" */)<%= (i + 1) < layoutsKeys.length ? ',' : '' %>
<% }) %> <% }) %>
} }

View File

@ -10,7 +10,7 @@ function recursiveRoutes(routes, tab, components) {
var res = '' var res = ''
routes.forEach((route, i) => { routes.forEach((route, i) => {
route._name = '_' + hash(route.component) route._name = '_' + hash(route.component)
components.push({ _name: route._name, component: route.component }) components.push({ _name: route._name, component: route.component, name: route.name })
res += tab + '{\n' res += tab + '{\n'
res += tab + '\tpath: ' + JSON.stringify(route.path) + ',\n' res += tab + '\tpath: ' + JSON.stringify(route.path) + ',\n'
res += tab + '\tcomponent: ' + route._name res += tab + '\tcomponent: ' + route._name
@ -23,7 +23,7 @@ function recursiveRoutes(routes, tab, components) {
var _components = [] var _components = []
var _routes = recursiveRoutes(router.routes, '\t\t', _components) var _routes = recursiveRoutes(router.routes, '\t\t', _components)
uniqBy(_components, '_name').forEach((route) => { %> uniqBy(_components, '_name').forEach((route) => { %>
const <%= route._name %> = () => import('<%= route.component %>') const <%= route._name %> = () => import('<%= route.component %>' /* webpackChunkName: "pages/<%= route.name %>" */)
<% }) %> <% }) %>
<% if (router.scrollBehavior) { %> <% if (router.scrollBehavior) { %>