mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 16:43:55 +00:00
Add webpackChunkName
This commit is contained in:
parent
6886f8bd57
commit
2eecb8c0de
@ -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 ? ',' : '' %>
|
||||||
<% }) %>
|
<% }) %>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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) { %>
|
||||||
|
Loading…
Reference in New Issue
Block a user