mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-29 09:02:03 +00:00
parent
ae32ca42fa
commit
99129216ee
@ -88,7 +88,7 @@ function advancedGet (obj = {}, query = '') {
|
|||||||
const v = get(i, l)
|
const v = get(i, l)
|
||||||
|
|
||||||
if (!v) {
|
if (!v) {
|
||||||
return
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@ -99,6 +99,8 @@ function advancedGet (obj = {}, query = '') {
|
|||||||
) {
|
) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
if (result.length === 1) {
|
if (result.length === 1) {
|
||||||
|
@ -385,8 +385,11 @@ function normalizeConfig (_options: CliConfiguration) {
|
|||||||
overrideProp(options.server, 'timing', { total: true, ...options.server.timing })
|
overrideProp(options.server, 'timing', { total: true, ...options.server.timing })
|
||||||
}
|
}
|
||||||
|
|
||||||
overrideProp(options, 'serverMiddleware', Array.isArray(options.serverMiddleware) ? options.serverMiddleware : Object.entries(options.serverMiddleware)
|
overrideProp(options, 'serverMiddleware',
|
||||||
.map(([path, handler]) => ({ path, handler }))
|
Array.isArray(options.serverMiddleware)
|
||||||
|
? options.serverMiddleware
|
||||||
|
: Object.entries(options.serverMiddleware)
|
||||||
|
.map(([path, handler]) => ({ path, handler }))
|
||||||
)
|
)
|
||||||
|
|
||||||
// Generate staticAssets
|
// Generate staticAssets
|
||||||
|
@ -329,7 +329,7 @@ export default class Generator {
|
|||||||
// If crawler activated and called from generateRoutes()
|
// If crawler activated and called from generateRoutes()
|
||||||
if (this.options.generate.crawler && this.options.render.ssr) {
|
if (this.options.generate.crawler && this.options.render.ssr) {
|
||||||
const possibleTrailingSlash = this.options.router.trailingSlash ? '/' : ''
|
const possibleTrailingSlash = this.options.router.trailingSlash ? '/' : ''
|
||||||
parse(html).querySelectorAll('a').map((el) => {
|
parse(html).querySelectorAll('a').forEach((el) => {
|
||||||
const sanitizedHref = (el.getAttribute('href') || '')
|
const sanitizedHref = (el.getAttribute('href') || '')
|
||||||
.replace(this.options.router.base, '/')
|
.replace(this.options.router.base, '/')
|
||||||
.replace(/\/+$/, '')
|
.replace(/\/+$/, '')
|
||||||
|
@ -15,7 +15,7 @@ export default async function renderAndGetWindow (
|
|||||||
loadedCallback,
|
loadedCallback,
|
||||||
loadingTimeout = 2000,
|
loadingTimeout = 2000,
|
||||||
globals
|
globals
|
||||||
}: Options
|
}: Partial<Options> = {}
|
||||||
) {
|
) {
|
||||||
const jsdom = await import('jsdom')
|
const jsdom = await import('jsdom')
|
||||||
.then(m => m.default || m)
|
.then(m => m.default || m)
|
||||||
|
@ -117,17 +117,21 @@ export const sortRoutes = function sortRoutes (routes: NuxtRouteConfig[]) {
|
|||||||
// If a.length >= b.length
|
// If a.length >= b.length
|
||||||
if (i === _b.length - 1 && res === 0) {
|
if (i === _b.length - 1 && res === 0) {
|
||||||
// unless * found sort by level, then alphabetically
|
// unless * found sort by level, then alphabetically
|
||||||
res = _a[i] === '*' ? -1 : (
|
res = _a[i] === '*'
|
||||||
_a.length === _b.length ? a.path.localeCompare(b.path) : (_a.length - _b.length)
|
? -1
|
||||||
)
|
: (
|
||||||
|
_a.length === _b.length ? a.path.localeCompare(b.path) : (_a.length - _b.length)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res === 0) {
|
if (res === 0) {
|
||||||
// unless * found sort by level, then alphabetically
|
// unless * found sort by level, then alphabetically
|
||||||
res = _a[i - 1] === '*' && _b[i] ? 1 : (
|
res = _a[i - 1] === '*' && _b[i]
|
||||||
_a.length === _b.length ? a.path.localeCompare(b.path) : (_a.length - _b.length)
|
? 1
|
||||||
)
|
: (
|
||||||
|
_a.length === _b.length ? a.path.localeCompare(b.path) : (_a.length - _b.length)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
})
|
})
|
||||||
|
@ -5,7 +5,7 @@ function contains (arr, val) {
|
|||||||
return arr && arr.includes(val)
|
return arr && arr.includes(val)
|
||||||
}
|
}
|
||||||
|
|
||||||
const atPrefix = new RegExp('^@', 'g')
|
const atPrefix = /^@/g
|
||||||
|
|
||||||
function readDir (dirName) {
|
function readDir (dirName) {
|
||||||
if (!fs.existsSync(dirName)) {
|
if (!fs.existsSync(dirName)) {
|
||||||
@ -95,10 +95,7 @@ function containsPattern (arr, val) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const scopedModuleRegex = new RegExp(
|
const scopedModuleRegex = /@[a-zA-Z0-9][\\w-.]+\/[a-zA-Z0-9][\\w-.]+([a-zA-Z0-9./]+)?/g
|
||||||
'@[a-zA-Z0-9][\\w-.]+/[a-zA-Z0-9][\\w-.]+([a-zA-Z0-9./]+)?',
|
|
||||||
'g'
|
|
||||||
)
|
|
||||||
|
|
||||||
function getModuleName (request, includeAbsolutePaths) {
|
function getModuleName (request, includeAbsolutePaths) {
|
||||||
let req = request
|
let req = request
|
||||||
|
@ -192,7 +192,8 @@ function getOutput (ctx: WebpackConfigContext): Configuration['output'] {
|
|||||||
path: resolve(options.buildDir, 'dist', ctx.isServer ? 'server' : 'client'),
|
path: resolve(options.buildDir, 'dist', ctx.isServer ? 'server' : 'client'),
|
||||||
filename: fileName(ctx, 'app'),
|
filename: fileName(ctx, 'app'),
|
||||||
chunkFilename: fileName(ctx, 'chunk'),
|
chunkFilename: fileName(ctx, 'chunk'),
|
||||||
publicPath: isUrl(options.build.publicPath) ? options.build.publicPath
|
publicPath: isUrl(options.build.publicPath)
|
||||||
|
? options.build.publicPath
|
||||||
: urlJoin(options.router.base, options.build.publicPath)
|
: urlJoin(options.router.base, options.build.publicPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ export default class PostcssConfig {
|
|||||||
const plugin = this.nuxt.resolver.requireModule(p)
|
const plugin = this.nuxt.resolver.requireModule(p)
|
||||||
const opts = plugins[p]
|
const opts = plugins[p]
|
||||||
if (opts === false) {
|
if (opts === false) {
|
||||||
return // Disabled
|
return false // Disabled
|
||||||
}
|
}
|
||||||
return plugin(opts)
|
return plugin(opts)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user