mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 09:27:13 +00:00
wChunk
This commit is contained in:
parent
6d9d949864
commit
1cc2c6b5b0
@ -16,7 +16,7 @@ let layouts = {
|
||||
<%
|
||||
var layoutsKeys = Object.keys(layouts);
|
||||
layoutsKeys.forEach(function (key, i) { %>
|
||||
"_<%= key %>": () => import('<%= layouts[key] %>' /* webpackChunkName: "<%= wp('layouts/'+key) %>" */).then(m => m.default || m)<%= (i + 1) < layoutsKeys.length ? ',' : '' %>
|
||||
"_<%= key %>": () => import('<%= layouts[key] %>' /* webpackChunkName: "<%= wChunk('layouts/'+key) %>" */).then(m => m.default || m)<%= (i + 1) < layoutsKeys.length ? ',' : '' %>
|
||||
<% }) %>
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ function recursiveRoutes(routes, tab, components) {
|
||||
}
|
||||
const _components = []
|
||||
const _routes = recursiveRoutes(router.routes, '\t\t', _components)
|
||||
uniqBy(_components, '_name').forEach((route) => { %>const <%= route._name %> = () => import('<%= relativeToBuild(route.component) %>' /* webpackChunkName: "pages/<%= wp(route.name) %>" */).then(m => m.default || m)
|
||||
uniqBy(_components, '_name').forEach((route) => { %>const <%= route._name %> = () => import('<%= relativeToBuild(route.component) %>' /* webpackChunkName: "<%= wChunk('pages/' + route.name) %>" */).then(m => m.default || m)
|
||||
<% }) %>
|
||||
|
||||
<% if (router.scrollBehavior) { %>
|
||||
|
@ -10,7 +10,7 @@ import Tapable from 'tappable'
|
||||
import MFS from 'memory-fs'
|
||||
import webpackDevMiddleware from 'webpack-dev-middleware'
|
||||
import webpackHotMiddleware from 'webpack-hot-middleware'
|
||||
import { r, wp, createRoutes, parallel, relativeTo, isPureObject } from 'utils'
|
||||
import { r, wp, wChunk, createRoutes, parallel, relativeTo, isPureObject } from 'utils'
|
||||
import Debug from 'debug'
|
||||
import Glob from 'glob'
|
||||
import clientWebpackConfig from './webpack/client.config.js'
|
||||
@ -286,6 +286,7 @@ export default class Builder extends Tapable {
|
||||
hash,
|
||||
r,
|
||||
wp,
|
||||
wChunk,
|
||||
resolvePath: this.nuxt.resolvePath.bind(this.nuxt),
|
||||
relativeToBuild: this.relativeToBuild
|
||||
}
|
||||
|
@ -84,10 +84,20 @@ export function isPureObject (o) {
|
||||
return !Array.isArray(o) && typeof o === 'object'
|
||||
}
|
||||
|
||||
export const isWindows = /^win/.test(process.platform)
|
||||
|
||||
export function wp (p) {
|
||||
/* istanbul ignore if */
|
||||
if (/^win/.test(process.platform)) {
|
||||
p = p.replace(/\\/g, '\\\\')
|
||||
if (isWindows) {
|
||||
return p.replace(/\\/g, '\\\\')
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
export function wChunk (p) {
|
||||
/* istanbul ignore if */
|
||||
if (isWindows) {
|
||||
return p.replace(/\//g, '\\')
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user