mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-19 23:21:09 +00:00
chore: cleanup (#4529)
This commit is contained in:
parent
683dbba4f7
commit
c60b1945e8
@ -1,7 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<p>Hi from {{ name }}</p>
|
<p>Hi from {{ name }}</p>
|
||||||
<n-link to="/">Home page</n-link>
|
<NLink to="/">
|
||||||
|
Home page
|
||||||
|
</NLink>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<h1>Welcome!</h1>
|
<h1>Welcome!</h1>
|
||||||
<n-link to="/about">About Page</n-link>
|
<NLink to="/about">
|
||||||
|
About Page
|
||||||
|
</NLink>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -314,7 +314,7 @@ export default class Builder {
|
|||||||
})).forEach((f) => {
|
})).forEach((f) => {
|
||||||
const key = f.replace(/\.(js|vue)$/, '')
|
const key = f.replace(/\.(js|vue)$/, '')
|
||||||
if (/\.vue$/.test(f) || !files[key]) {
|
if (/\.vue$/.test(f) || !files[key]) {
|
||||||
files[key] = f.replace(/('|")/g, '\\$1')
|
files[key] = f.replace(/(['"])/g, '\\$1')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
templateVars.router.routes = createRoutes(
|
templateVars.router.routes = createRoutes(
|
||||||
|
@ -18,7 +18,7 @@ export default async function listCommands() {
|
|||||||
maxLength = Math.max(maxLength, _commands[name].usage.length)
|
maxLength = Math.max(maxLength, _commands[name].usage.length)
|
||||||
}
|
}
|
||||||
|
|
||||||
const _cmmds = commandsHelp.map(([cmd, description]) => {
|
const _cmds = commandsHelp.map(([cmd, description]) => {
|
||||||
const i = indent(maxLength + optionSpaces - cmd.length)
|
const i = indent(maxLength + optionSpaces - cmd.length)
|
||||||
return foldLines(
|
return foldLines(
|
||||||
chalk.green(cmd) + i + description,
|
chalk.green(cmd) + i + description,
|
||||||
@ -28,7 +28,7 @@ export default async function listCommands() {
|
|||||||
}).join('\n')
|
}).join('\n')
|
||||||
|
|
||||||
const usage = foldLines(`Usage: nuxt <command> [--help|-h]`, startSpaces)
|
const usage = foldLines(`Usage: nuxt <command> [--help|-h]`, startSpaces)
|
||||||
const cmmds = foldLines(`Commands:`, startSpaces) + '\n\n' + _cmmds
|
const cmds = foldLines(`Commands:`, startSpaces) + '\n\n' + _cmds
|
||||||
|
|
||||||
process.stderr.write(colorize(`${usage}\n\n${cmmds}\n\n`))
|
process.stderr.write(colorize(`${usage}\n\n${cmds}\n\n`))
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ export function foldLines(string, spaces, firstLineSpaces, maxCharsPerLine) {
|
|||||||
|
|
||||||
export function colorize(text) {
|
export function colorize(text) {
|
||||||
return text
|
return text
|
||||||
.replace(/\[[^ ]+\]/g, m => chalk.grey(m))
|
.replace(/\[[^ ]+]/g, m => chalk.grey(m))
|
||||||
.replace(/<[^ ]+>/g, m => chalk.green(m))
|
.replace(/<[^ ]+>/g, m => chalk.green(m))
|
||||||
.replace(/ (-[-\w,]+)/g, m => chalk.bold(m))
|
.replace(/ (-[-\w,]+)/g, m => chalk.bold(m))
|
||||||
.replace(/`(.+)`/g, (_, m) => chalk.bold.cyan(m))
|
.replace(/`(.+)`/g, (_, m) => chalk.bold.cyan(m))
|
||||||
|
@ -256,7 +256,7 @@ function cleanChildrenRoutes(routes, isChild = false) {
|
|||||||
return routes
|
return routes
|
||||||
}
|
}
|
||||||
|
|
||||||
const DYNAMIC_ROUTE_REGEX = /^\/(:|\*)/
|
const DYNAMIC_ROUTE_REGEX = /^\/([:*])/
|
||||||
|
|
||||||
const sortRoutes = function sortRoutes(routes) {
|
const sortRoutes = function sortRoutes(routes) {
|
||||||
routes.sort((a, b) => {
|
routes.sort((a, b) => {
|
||||||
|
@ -70,7 +70,7 @@ export function getNuxtConfig(_options) {
|
|||||||
|
|
||||||
defaultsDeep(options, nuxtConfig)
|
defaultsDeep(options, nuxtConfig)
|
||||||
|
|
||||||
// Check srcDir and generate.dir excistence
|
// Check srcDir and generate.dir existence
|
||||||
const hasSrcDir = isNonEmptyString(options.srcDir)
|
const hasSrcDir = isNonEmptyString(options.srcDir)
|
||||||
const hasGenerateDir = isNonEmptyString(options.generate.dir)
|
const hasGenerateDir = isNonEmptyString(options.generate.dir)
|
||||||
|
|
||||||
|
@ -22,10 +22,9 @@ export default class Resolver {
|
|||||||
|
|
||||||
resolveModule(path) {
|
resolveModule(path) {
|
||||||
try {
|
try {
|
||||||
const resolvedPath = Module._resolveFilename(path, {
|
return Module._resolveFilename(path, {
|
||||||
paths: this.options.modulesDir
|
paths: this.options.modulesDir
|
||||||
})
|
})
|
||||||
return resolvedPath
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.code === 'MODULE_NOT_FOUND') {
|
if (error.code === 'MODULE_NOT_FOUND') {
|
||||||
return undefined
|
return undefined
|
||||||
|
@ -104,8 +104,8 @@ export default {
|
|||||||
},
|
},
|
||||||
loadLayout(layout) {
|
loadLayout(layout) {
|
||||||
const undef = !layout
|
const undef = !layout
|
||||||
const inexisting = !(layouts['_' + layout] || resolvedLayouts['_' + layout])
|
const nonexistent = !(layouts['_' + layout] || resolvedLayouts['_' + layout])
|
||||||
let _layout = '_' + ((undef || inexisting) ? 'default' : layout)
|
let _layout = '_' + ((undef || nonexistent) ? 'default' : layout)
|
||||||
if (resolvedLayouts[_layout]) {
|
if (resolvedLayouts[_layout]) {
|
||||||
return Promise.resolve(resolvedLayouts[_layout])
|
return Promise.resolve(resolvedLayouts[_layout])
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ export default class SPAMetaRenderer {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async getMeta(url) {
|
async getMeta() {
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
render: h => h(), // Render empty html tag
|
render: h => h(), // Render empty html tag
|
||||||
head: this.options.head || {}
|
head: this.options.head || {}
|
||||||
@ -45,7 +45,7 @@ export default class SPAMetaRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get vue-meta context
|
// Get vue-meta context
|
||||||
const m = await this.getMeta(url)
|
const m = await this.getMeta()
|
||||||
|
|
||||||
// HTML_ATTRS
|
// HTML_ATTRS
|
||||||
meta.HTML_ATTRS = m.htmlAttrs.text()
|
meta.HTML_ATTRS = m.htmlAttrs.text()
|
||||||
|
@ -31,7 +31,7 @@ export class WebpackBundler {
|
|||||||
if (this.context.options.dev) {
|
if (this.context.options.dev) {
|
||||||
this.mfs = new MFS()
|
this.mfs = new MFS()
|
||||||
|
|
||||||
// TODO: Enable when async FS rquired
|
// TODO: Enable when async FS required
|
||||||
// this.mfs.exists = function (...args) { return Promise.resolve(this.existsSync(...args)) }
|
// this.mfs.exists = function (...args) { return Promise.resolve(this.existsSync(...args)) }
|
||||||
// this.mfs.readFile = function (...args) { return Promise.resolve(this.readFileSync(...args)) }
|
// this.mfs.readFile = function (...args) { return Promise.resolve(this.readFileSync(...args)) }
|
||||||
}
|
}
|
||||||
@ -108,7 +108,7 @@ export class WebpackBundler {
|
|||||||
return compiler
|
return compiler
|
||||||
})
|
})
|
||||||
|
|
||||||
// Warmup perfLoader before build
|
// Warm up perfLoader before build
|
||||||
if (options.build.parallel) {
|
if (options.build.parallel) {
|
||||||
consola.info('Warming up worker pools')
|
consola.info('Warming up worker pools')
|
||||||
PerfLoader.warmupAll({ dev: options.dev })
|
PerfLoader.warmupAll({ dev: options.dev })
|
||||||
@ -172,7 +172,7 @@ export class WebpackBundler {
|
|||||||
if (options.build.quiet === true) {
|
if (options.build.quiet === true) {
|
||||||
return Promise.reject(stats.toString(options.build.stats))
|
return Promise.reject(stats.toString(options.build.stats))
|
||||||
} else {
|
} else {
|
||||||
// Actual error will be printet by webpack
|
// Actual error will be printed by webpack
|
||||||
throw new Error('Nuxt Build Error')
|
throw new Error('Nuxt Build Error')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ export default class WebpackBaseConfig {
|
|||||||
fileName = fileName(this.nuxtEnv)
|
fileName = fileName(this.nuxtEnv)
|
||||||
}
|
}
|
||||||
if (this.options.dev) {
|
if (this.options.dev) {
|
||||||
const hash = /\[(chunkhash|contenthash|hash)(?::(\d+))?\]/.exec(fileName)
|
const hash = /\[(chunkhash|contenthash|hash)(?::(\d+))?]/.exec(fileName)
|
||||||
if (hash) {
|
if (hash) {
|
||||||
consola.warn(`Notice: Please do not use ${hash[1]} in dev mode to prevent memory leak`)
|
consola.warn(`Notice: Please do not use ${hash[1]} in dev mode to prevent memory leak`)
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,10 @@
|
|||||||
export default class WarnFixPlugin {
|
export default class WarnFixPlugin {
|
||||||
apply(compiler) /* istanbul ignore next */ {
|
apply(compiler) /* istanbul ignore next */ {
|
||||||
compiler.hooks.done.tap('warnfix-plugin', (stats) => {
|
compiler.hooks.done.tap('warnfix-plugin', (stats) => {
|
||||||
stats.compilation.warnings = stats.compilation.warnings.filter((warn) => {
|
stats.compilation.warnings = stats.compilation.warnings.filter(warn =>
|
||||||
if (
|
!(warn.name === 'ModuleDependencyWarning' &&
|
||||||
warn.name === 'ModuleDependencyWarning' &&
|
|
||||||
warn.message.includes(`export 'default'`) &&
|
warn.message.includes(`export 'default'`) &&
|
||||||
warn.message.includes('nuxt_plugin_')
|
warn.message.includes('nuxt_plugin_')))
|
||||||
) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,8 +118,7 @@ export default class PostcssConfig {
|
|||||||
if (opts === false) {
|
if (opts === false) {
|
||||||
return // Disabled
|
return // Disabled
|
||||||
}
|
}
|
||||||
const instance = plugin(opts)
|
return plugin(opts)
|
||||||
return instance
|
|
||||||
})
|
})
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
}
|
}
|
||||||
|
4
test/fixtures/spa/layouts/custom.vue
vendored
4
test/fixtures/spa/layouts/custom.vue
vendored
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
Custom layout
|
Custom layout
|
||||||
<br>
|
<br>
|
||||||
<Nuxt />
|
<Nuxt />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
4
test/fixtures/spa/layouts/default.vue
vendored
4
test/fixtures/spa/layouts/default.vue
vendored
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
Default layout
|
Default layout
|
||||||
<br>
|
<br>
|
||||||
<Nuxt />
|
<Nuxt />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
Loading…
Reference in New Issue
Block a user