mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
Merge branch '3.x' into config-types
This commit is contained in:
commit
8ac0a7cec6
@ -4,6 +4,7 @@ import chokidar from 'chokidar'
|
|||||||
import consola from 'consola'
|
import consola from 'consola'
|
||||||
import fsExtra from 'fs-extra'
|
import fsExtra from 'fs-extra'
|
||||||
import Glob from 'glob'
|
import Glob from 'glob'
|
||||||
|
import globby from 'globby'
|
||||||
import hash from 'hash-sum'
|
import hash from 'hash-sum'
|
||||||
import pify from 'pify'
|
import pify from 'pify'
|
||||||
import upath from 'upath'
|
import upath from 'upath'
|
||||||
@ -16,9 +17,8 @@ import template from 'lodash/template'
|
|||||||
import uniq from 'lodash/uniq'
|
import uniq from 'lodash/uniq'
|
||||||
import uniqBy from 'lodash/uniqBy'
|
import uniqBy from 'lodash/uniqBy'
|
||||||
|
|
||||||
import type { Nuxt } from 'nuxt/core'
|
import { BundleBuilder } from 'src/webpack'
|
||||||
import { BundleBuilder } from 'nuxt/webpack'
|
import type { Nuxt } from 'src/core'
|
||||||
import vueAppTemplate from 'nuxt/vue-app/template'
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
r,
|
r,
|
||||||
@ -32,7 +32,7 @@ import {
|
|||||||
scanRequireTree,
|
scanRequireTree,
|
||||||
TARGETS,
|
TARGETS,
|
||||||
isFullStatic
|
isFullStatic
|
||||||
} from 'nuxt/utils'
|
} from 'src/utils'
|
||||||
|
|
||||||
import Ignore from './ignore'
|
import Ignore from './ignore'
|
||||||
import BuildContext from './context/build'
|
import BuildContext from './context/build'
|
||||||
@ -104,8 +104,7 @@ export default class Builder {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolve template
|
this.resolveAppTemplate()
|
||||||
this.template = vueAppTemplate
|
|
||||||
|
|
||||||
// Create a new bundle builder
|
// Create a new bundle builder
|
||||||
this.bundleBuilder = this.getBundleBuilder()
|
this.bundleBuilder = this.getBundleBuilder()
|
||||||
@ -124,6 +123,18 @@ export default class Builder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resolveAppTemplate() {
|
||||||
|
// Resolve appDir
|
||||||
|
const templatesDir = path.join(this.options.appDir, '_templates')
|
||||||
|
const files = globby.sync(path.join(templatesDir, '/**'))
|
||||||
|
.map(f => f.replace(templatesDir + path.sep, ''))
|
||||||
|
this.template = {
|
||||||
|
dependencies: {},
|
||||||
|
dir: templatesDir,
|
||||||
|
files
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getBundleBuilder () {
|
getBundleBuilder () {
|
||||||
const context = new BuildContext(this)
|
const context = new BuildContext(this)
|
||||||
return new BundleBuilder(context)
|
return new BundleBuilder(context)
|
||||||
@ -196,7 +207,7 @@ export default class Builder {
|
|||||||
// Generate routes and interpret the template files
|
// Generate routes and interpret the template files
|
||||||
await this.generateRoutesAndFiles()
|
await this.generateRoutesAndFiles()
|
||||||
|
|
||||||
// Add vue-app template dir to watchers
|
// Add app template dir to watchers
|
||||||
this.options.build.watch.push(this.globPathWithExtensions(this.template.dir))
|
this.options.build.watch.push(this.globPathWithExtensions(this.template.dir))
|
||||||
|
|
||||||
await this.resolvePlugins()
|
await this.resolvePlugins()
|
||||||
@ -362,8 +373,8 @@ export default class Builder {
|
|||||||
return (await this.resolveFiles(dir)).map(file => ({ src: file.replace(dirPrefix, '') }))
|
return (await this.resolveFiles(dir)).map(file => ({ src: file.replace(dirPrefix, '') }))
|
||||||
}
|
}
|
||||||
|
|
||||||
async resolveApp({ templateVars }) {
|
async resolveApp ({ templateVars }) {
|
||||||
templateVars.appPath = 'nuxt-app/app.tutorial.vue'
|
templateVars.appPath = 'app/app.tutorial.vue'
|
||||||
|
|
||||||
for (const appFile of this.appFiles) {
|
for (const appFile of this.appFiles) {
|
||||||
if (await fsExtra.exists(appFile)) {
|
if (await fsExtra.exists(appFile)) {
|
||||||
@ -530,7 +541,7 @@ export default class Builder {
|
|||||||
// Modules & user provided templates
|
// Modules & user provided templates
|
||||||
// first custom to keep their index
|
// first custom to keep their index
|
||||||
...customTemplateFiles,
|
...customTemplateFiles,
|
||||||
// @nuxt/vue-app templates
|
// @nuxt/app templates
|
||||||
...templateContext.templateFiles
|
...templateContext.templateFiles
|
||||||
])
|
])
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@ import uniqBy from 'lodash/uniqBy'
|
|||||||
import serialize from 'serialize-javascript'
|
import serialize from 'serialize-javascript'
|
||||||
|
|
||||||
import devalue from '@nuxt/devalue'
|
import devalue from '@nuxt/devalue'
|
||||||
import { NormalizedConfiguration } from 'nuxt/config'
|
import { NormalizedConfiguration } from 'src/config'
|
||||||
import { r, wp, wChunk, serializeFunction, isFullStatic } from 'nuxt/utils'
|
import { r, wp, wChunk, serializeFunction, isFullStatic } from 'src/utils'
|
||||||
|
|
||||||
import type Builder from '../builder'
|
import type Builder from '../builder'
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import fs from 'fs-extra'
|
import fs from 'fs-extra'
|
||||||
import ignore from 'ignore'
|
import ignore from 'ignore'
|
||||||
import { NormalizedConfiguration } from 'nuxt/config'
|
import { NormalizedConfiguration } from 'src/config'
|
||||||
|
|
||||||
type IgnoreInstance = ReturnType<typeof ignore>
|
type IgnoreInstance = ReturnType<typeof ignore>
|
||||||
type IgnoreOptions = Parameters<typeof ignore>[0]
|
type IgnoreOptions = Parameters<typeof ignore>[0]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { Nuxt } from 'nuxt/core'
|
import type { Nuxt } from 'src/core'
|
||||||
|
|
||||||
import Builder from './builder'
|
import Builder from './builder'
|
||||||
export { default as Builder } from './builder'
|
export { default as Builder } from './builder'
|
||||||
|
@ -4,10 +4,10 @@ import consola from 'consola'
|
|||||||
import minimist, { Opts as MinimistOptions, ParsedArgs } from 'minimist'
|
import minimist, { Opts as MinimistOptions, ParsedArgs } from 'minimist'
|
||||||
import Hookable from 'hookable'
|
import Hookable from 'hookable'
|
||||||
|
|
||||||
import { Builder } from 'nuxt/builder'
|
import { Builder } from 'src/builder'
|
||||||
import { CliConfiguration } from 'nuxt/config/options'
|
import { CliConfiguration } from 'src/config/options'
|
||||||
import { Nuxt } from 'nuxt/core'
|
import { Nuxt } from 'src/core'
|
||||||
import { Generator } from 'nuxt/generator'
|
import { Generator } from 'src/generator'
|
||||||
|
|
||||||
import { name, version } from '../../package.json'
|
import { name, version } from '../../package.json'
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import consola from 'consola'
|
import consola from 'consola'
|
||||||
|
import { MODES, TARGETS } from 'src/utils'
|
||||||
import type { ParsedArgs } from 'minimist'
|
import type { ParsedArgs } from 'minimist'
|
||||||
|
|
||||||
import { MODES, TARGETS } from 'nuxt/utils'
|
|
||||||
import NuxtCommand from '../command'
|
import NuxtCommand from '../command'
|
||||||
import { common, locking } from '../options'
|
import { common, locking } from '../options'
|
||||||
import { createLock } from '../utils'
|
import { createLock } from '../utils'
|
||||||
|
@ -3,7 +3,7 @@ import chalk from 'chalk'
|
|||||||
import opener from 'opener'
|
import opener from 'opener'
|
||||||
import type { ParsedArgs } from 'minimist'
|
import type { ParsedArgs } from 'minimist'
|
||||||
|
|
||||||
import { Nuxt } from 'nuxt/core'
|
import { Nuxt } from 'src/core'
|
||||||
|
|
||||||
import type NuxtCommand from '../command'
|
import type NuxtCommand from '../command'
|
||||||
import { common, server } from '../options'
|
import { common, server } from '../options'
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import consola from 'consola'
|
import consola from 'consola'
|
||||||
import { TARGETS } from 'nuxt/utils'
|
import { TARGETS } from 'src/utils'
|
||||||
import type NuxtCommand from '../command'
|
import type NuxtCommand from '../command'
|
||||||
import { common, locking } from '../options'
|
import { common, locking } from '../options'
|
||||||
import { createLock } from '../utils'
|
import { createLock } from '../utils'
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
import { TARGETS } from 'src/utils'
|
||||||
import type { ParsedArgs } from 'minimist'
|
import type { ParsedArgs } from 'minimist'
|
||||||
import { TARGETS } from 'nuxt/utils'
|
|
||||||
import type NuxtCommand from '../command'
|
import type NuxtCommand from '../command'
|
||||||
import { common, locking } from '../options'
|
import { common, locking } from '../options'
|
||||||
import { normalizeArg, createLock } from '../utils'
|
import { normalizeArg, createLock } from '../utils'
|
||||||
|
@ -3,13 +3,13 @@ import { join, extname, basename } from 'path'
|
|||||||
import connect from 'connect'
|
import connect from 'connect'
|
||||||
import serveStatic from 'serve-static'
|
import serveStatic from 'serve-static'
|
||||||
import compression from 'compression'
|
import compression from 'compression'
|
||||||
import { getNuxtConfig } from 'nuxt/config'
|
import { getNuxtConfig } from 'src/config'
|
||||||
import { TARGETS } from 'nuxt/utils'
|
import { TARGETS } from 'src/utils'
|
||||||
import { Listener } from 'nuxt/server'
|
|
||||||
import { Nuxt } from 'nuxt/core'
|
|
||||||
import type NuxtCommand from '../command'
|
|
||||||
import { common, server } from '../options'
|
import { common, server } from '../options'
|
||||||
import { showBanner } from '../utils/banner'
|
import { showBanner } from '../utils/banner'
|
||||||
|
import { Listener } from 'src/server'
|
||||||
|
import { Nuxt } from 'src/core'
|
||||||
|
import type NuxtCommand from '../command'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'serve',
|
name: 'serve',
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { TARGETS } from 'nuxt/utils'
|
import { TARGETS } from 'src/utils'
|
||||||
|
|
||||||
import type NuxtCommand from '../command'
|
import type NuxtCommand from '../command'
|
||||||
import { common, server } from '../options'
|
import { common, server } from '../options'
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { defaultNuxtConfigFile } from 'nuxt/config'
|
import { defaultNuxtConfigFile } from 'src/config'
|
||||||
import { normalizeArg } from '../utils'
|
import { normalizeArg } from '../utils'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import consola from 'consola'
|
import consola from 'consola'
|
||||||
import type { ParsedArgs } from 'minimist'
|
import type { ParsedArgs } from 'minimist'
|
||||||
|
|
||||||
import { Configuration } from 'nuxt/config/options'
|
import { Configuration } from 'src/config/options'
|
||||||
|
|
||||||
import NuxtCommand from '../command'
|
import NuxtCommand from '../command'
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ import consola from 'consola'
|
|||||||
import env from 'std-env'
|
import env from 'std-env'
|
||||||
import chalk from 'chalk'
|
import chalk from 'chalk'
|
||||||
|
|
||||||
import { Nuxt } from 'nuxt/core'
|
import { Nuxt } from 'src/core'
|
||||||
import { successBox } from './formatting'
|
import { successBox } from './formatting'
|
||||||
import { getFormattedMemoryUsage } from './memory'
|
import { getFormattedMemoryUsage } from './memory'
|
||||||
|
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import defaultsDeep from 'lodash/defaultsDeep'
|
import defaultsDeep from 'lodash/defaultsDeep'
|
||||||
|
import { loadNuxtConfig as _loadNuxtConfig, getDefaultNuxtConfig } from 'src/config'
|
||||||
|
import { MODES } from 'src/utils'
|
||||||
import type { ParsedArgs } from 'minimist'
|
import type { ParsedArgs } from 'minimist'
|
||||||
|
|
||||||
import { loadNuxtConfig as _loadNuxtConfig, getDefaultNuxtConfig } from 'nuxt/config'
|
|
||||||
import { MODES } from 'nuxt/utils'
|
|
||||||
|
|
||||||
export async function loadNuxtConfig (argv: ParsedArgs, configContext) {
|
export async function loadNuxtConfig (argv: ParsedArgs, configContext) {
|
||||||
const rootDir = path.resolve(argv._[0] || '.')
|
const rootDir = path.resolve(argv._[0] || '.')
|
||||||
const configFile = argv['config-file']
|
const configFile = argv['config-file']
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import exit from 'exit'
|
import exit from 'exit'
|
||||||
|
|
||||||
import { lock } from 'nuxt/utils'
|
import { lock } from 'src/utils'
|
||||||
import chalk from 'chalk'
|
import chalk from 'chalk'
|
||||||
import env from 'std-env'
|
import env from 'std-env'
|
||||||
import { warningBox } from './formatting'
|
import { warningBox } from './formatting'
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { loadNuxt } from 'nuxt/core'
|
import { loadNuxt } from 'src/core'
|
||||||
import { getBuilder } from 'nuxt/builder'
|
import { getBuilder } from 'src/builder'
|
||||||
|
|
||||||
export async function getWebpackConfig (name = 'client', loadOptions = {}) {
|
export async function getWebpackConfig (name = 'client', loadOptions = {}) {
|
||||||
const nuxt = await loadNuxt(loadOptions)
|
const nuxt = await loadNuxt(loadOptions)
|
||||||
|
@ -5,8 +5,8 @@ import ignore from 'ignore'
|
|||||||
import capitalize from 'lodash/capitalize'
|
import capitalize from 'lodash/capitalize'
|
||||||
import env from 'std-env'
|
import env from 'std-env'
|
||||||
import type { Configuration as WebpackConfiguration } from 'webpack'
|
import type { Configuration as WebpackConfiguration } from 'webpack'
|
||||||
|
import path from 'path'
|
||||||
import { TARGETS, MODES, Target, Mode } from 'nuxt/utils'
|
import { TARGETS, MODES, Target, Mode } from 'src/utils'
|
||||||
|
|
||||||
import type { NormalizedConfiguration } from '../options'
|
import type { NormalizedConfiguration } from '../options'
|
||||||
import Hookable from 'hookable'
|
import Hookable from 'hookable'
|
||||||
@ -172,6 +172,7 @@ export default (): CommonConfiguration => ({
|
|||||||
modulesDir: [
|
modulesDir: [
|
||||||
'node_modules'
|
'node_modules'
|
||||||
],
|
],
|
||||||
|
appDir: path.resolve(__dirname, '../../../app'),
|
||||||
dir: {
|
dir: {
|
||||||
assets: 'assets',
|
assets: 'assets',
|
||||||
app: 'app',
|
app: 'app',
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { MODES } from 'nuxt/utils'
|
import { MODES } from 'src/utils'
|
||||||
|
|
||||||
export default () => ({
|
export default () => ({
|
||||||
[MODES.universal]: {
|
[MODES.universal]: {
|
||||||
|
@ -3,15 +3,15 @@ import fs from 'fs'
|
|||||||
import defu from 'defu'
|
import defu from 'defu'
|
||||||
import consola from 'consola'
|
import consola from 'consola'
|
||||||
import dotenv from 'dotenv'
|
import dotenv from 'dotenv'
|
||||||
import { clearRequireCache, scanRequireTree } from 'nuxt/utils'
|
import { clearRequireCache, scanRequireTree } from 'src/utils'
|
||||||
import jiti from 'jiti'
|
import jiti from 'jiti'
|
||||||
import _createRequire from 'create-require'
|
import _createRequire from 'create-require'
|
||||||
import destr from 'destr'
|
import destr from 'destr'
|
||||||
import * as rc from 'rc9'
|
import * as rc from 'rc9'
|
||||||
|
|
||||||
import { LoadOptions } from 'nuxt/core/load'
|
import { LoadOptions } from 'src/core/load'
|
||||||
import { defaultNuxtConfigFile } from './config'
|
import { defaultNuxtConfigFile } from './config'
|
||||||
import { CliConfiguration, Configuration } from 'nuxt/config/options'
|
import { CliConfiguration, Configuration } from 'src/config/options'
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const isJest = typeof jest !== 'undefined'
|
const isJest = typeof jest !== 'undefined'
|
||||||
|
@ -2,16 +2,14 @@ import path from 'path'
|
|||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import consola from 'consola'
|
import consola from 'consola'
|
||||||
import defu from 'defu'
|
import defu from 'defu'
|
||||||
import destr from 'destr'
|
|
||||||
import defaultsDeep from 'lodash/defaultsDeep'
|
import defaultsDeep from 'lodash/defaultsDeep'
|
||||||
import pick from 'lodash/pick'
|
import pick from 'lodash/pick'
|
||||||
import uniq from 'lodash/uniq'
|
import uniq from 'lodash/uniq'
|
||||||
|
import destr from 'destr'
|
||||||
import { TARGETS, MODES, guardDir, isNonEmptyString, isPureObject, isUrl, getMainModule, urlJoin, getPKG, Target, Mode } from 'nuxt/utils'
|
import { TARGETS, MODES, guardDir, isNonEmptyString, isPureObject, isUrl, getMainModule, urlJoin, getPKG } from 'src/utils'
|
||||||
|
|
||||||
import { DefaultConfiguration, defaultNuxtConfigFile, getDefaultNuxtConfig } from './config'
|
import { DefaultConfiguration, defaultNuxtConfigFile, getDefaultNuxtConfig } from './config'
|
||||||
import { deleteProp, mergeConfigs, setProp, overrideProp, Optional } from './transformers'
|
import { deleteProp, mergeConfigs, setProp, overrideProp, Optional } from './transformers'
|
||||||
import type { EnvConfig } from 'nuxt/config/load'
|
import type { EnvConfig } from 'src/config/load'
|
||||||
|
|
||||||
interface InputConfiguration {
|
interface InputConfiguration {
|
||||||
appTemplatePath?: string
|
appTemplatePath?: string
|
||||||
@ -368,6 +366,8 @@ function normalizeConfig(_options: CliConfiguration) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
overrideProp(options.build, 'transpile', Array.from(options.build.transpile || []))
|
overrideProp(options.build, 'transpile', Array.from(options.build.transpile || []))
|
||||||
|
options.build.transpile = [].concat(options.build.transpile || [])
|
||||||
|
options.build.transpile.push('app')
|
||||||
|
|
||||||
if (options.build.quiet === true) {
|
if (options.build.quiet === true) {
|
||||||
consola.level = 0
|
consola.level = 0
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
export { default as Module } from './module'
|
export { default as Module } from './module'
|
||||||
export { default as Nuxt } from './nuxt'
|
export { default as Nuxt } from './nuxt'
|
||||||
export { default as Resolver } from './resolver'
|
export { default as Resolver } from './resolver'
|
||||||
export { loadNuxtConfig } from 'nuxt/config'
|
export { loadNuxtConfig } from 'src/config'
|
||||||
export { loadNuxt } from './load'
|
export { loadNuxt } from './load'
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { EnvConfig } from 'nuxt/config/load'
|
import { EnvConfig } from 'src/config/load'
|
||||||
import { loadNuxtConfig } from '../config'
|
import { loadNuxtConfig } from '../config'
|
||||||
import Nuxt from './nuxt'
|
import Nuxt from './nuxt'
|
||||||
|
|
||||||
|
@ -3,11 +3,11 @@ import fs from 'fs'
|
|||||||
import hash from 'hash-sum'
|
import hash from 'hash-sum'
|
||||||
import consola from 'consola'
|
import consola from 'consola'
|
||||||
|
|
||||||
import type { NormalizedConfiguration } from 'nuxt/config'
|
import type { NormalizedConfiguration } from 'src/config'
|
||||||
import { chainFn, Mode, sequence } from 'nuxt/utils'
|
import { chainFn, sequence } from 'src/utils'
|
||||||
|
|
||||||
import Nuxt from './nuxt'
|
import Nuxt from './nuxt'
|
||||||
import type { NuxtModule, ModuleHandler } from 'nuxt/config/config/_common'
|
import type { NuxtModule, ModuleHandler } from 'src/config/config/_common'
|
||||||
|
|
||||||
interface TemplateInput {
|
interface TemplateInput {
|
||||||
filename?: string
|
filename?: string
|
||||||
|
@ -3,9 +3,9 @@ import isPlainObject from 'lodash/isPlainObject'
|
|||||||
import consola from 'consola'
|
import consola from 'consola'
|
||||||
import Hookable from 'hookable'
|
import Hookable from 'hookable'
|
||||||
|
|
||||||
import { defineAlias } from 'nuxt/utils'
|
import { defineAlias } from 'src/utils'
|
||||||
import { getNuxtConfig, Configuration, NormalizedConfiguration } from 'nuxt/config'
|
import { getNuxtConfig, Configuration, NormalizedConfiguration } from 'src/config'
|
||||||
import { Server } from 'nuxt/server'
|
import { Server } from 'src/server'
|
||||||
|
|
||||||
import { version } from '../../package.json'
|
import { version } from '../../package.json'
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import { resolve, join } from 'path'
|
import { resolve, join } from 'path'
|
||||||
import fs from 'fs-extra'
|
import fs from 'fs-extra'
|
||||||
|
|
||||||
import { Nuxt } from 'nuxt/core'
|
import { Nuxt } from 'src/core'
|
||||||
import {
|
import {
|
||||||
startsWithRootAlias,
|
startsWithRootAlias,
|
||||||
startsWithSrcAlias,
|
startsWithSrcAlias,
|
||||||
isExternalDependency,
|
isExternalDependency,
|
||||||
clearRequireCache
|
clearRequireCache
|
||||||
} from 'nuxt/utils'
|
} from 'src/utils'
|
||||||
|
|
||||||
interface ResolvePathOptions {
|
interface ResolvePathOptions {
|
||||||
isAlias?: boolean
|
isAlias?: boolean
|
||||||
|
@ -6,9 +6,9 @@ import defu from 'defu'
|
|||||||
import htmlMinifier from 'html-minifier'
|
import htmlMinifier from 'html-minifier'
|
||||||
import { parse } from 'node-html-parser'
|
import { parse } from 'node-html-parser'
|
||||||
|
|
||||||
import type { Builder } from 'nuxt/builder'
|
import type { Builder } from 'src/builder'
|
||||||
import type { Nuxt } from 'nuxt/core'
|
import type { Nuxt } from 'src/core'
|
||||||
import { isFullStatic, flatRoutes, isString, isUrl, promisifyRoute, waitFor, TARGETS } from 'nuxt/utils'
|
import { isFullStatic, flatRoutes, isString, isUrl, promisifyRoute, waitFor, TARGETS } from 'src/utils'
|
||||||
|
|
||||||
export default class Generator {
|
export default class Generator {
|
||||||
_payload: null
|
_payload: null
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { Nuxt } from 'nuxt/core'
|
import type { Nuxt } from 'src/core'
|
||||||
|
|
||||||
import Generator from './generator'
|
import Generator from './generator'
|
||||||
export { default as Generator } from './generator'
|
export { default as Generator } from './generator'
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Server } from 'nuxt/server'
|
import { Server } from 'src/server'
|
||||||
|
|
||||||
export default class ServerContext {
|
export default class ServerContext {
|
||||||
nuxt: Server['nuxt']
|
nuxt: Server['nuxt']
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import consola from 'consola'
|
import consola from 'consola'
|
||||||
import { BaseOptions, DOMWindow, VirtualConsole } from 'jsdom'
|
import { BaseOptions, DOMWindow, VirtualConsole } from 'jsdom'
|
||||||
import { DeterminedGlobals, timeout } from 'nuxt/utils'
|
import { DeterminedGlobals, timeout } from 'src/utils'
|
||||||
|
|
||||||
interface Options {
|
interface Options {
|
||||||
globals: DeterminedGlobals
|
globals: DeterminedGlobals
|
||||||
|
@ -2,7 +2,7 @@ import generateETag from 'etag'
|
|||||||
import fresh from 'fresh'
|
import fresh from 'fresh'
|
||||||
import consola from 'consola'
|
import consola from 'consola'
|
||||||
|
|
||||||
import { getContext, TARGETS } from 'nuxt/utils'
|
import { getContext, TARGETS } from 'src/utils'
|
||||||
|
|
||||||
export default ({ options, nuxt, renderRoute, resources }) => async function nuxtMiddleware (req, res, next) {
|
export default ({ options, nuxt, renderRoute, resources }) => async function nuxtMiddleware (req, res, next) {
|
||||||
// Get context
|
// Get context
|
||||||
|
@ -3,7 +3,7 @@ import type { IncomingMessage } from 'connect'
|
|||||||
|
|
||||||
import consola from 'consola'
|
import consola from 'consola'
|
||||||
import onHeaders from 'on-headers'
|
import onHeaders from 'on-headers'
|
||||||
import { Timer } from 'nuxt/utils'
|
import { Timer } from 'src/utils'
|
||||||
|
|
||||||
export default options => (_req: IncomingMessage, res: ServerResponse & { timing?: ServerTiming }, next: (err?: any) => void) => {
|
export default options => (_req: IncomingMessage, res: ServerResponse & { timing?: ServerTiming }, next: (err?: any) => void) => {
|
||||||
if (res.timing) {
|
if (res.timing) {
|
||||||
|
@ -7,9 +7,9 @@ import servePlaceholder from 'serve-placeholder'
|
|||||||
import connect, { IncomingMessage } from 'connect'
|
import connect, { IncomingMessage } from 'connect'
|
||||||
import type { TemplateExecutor } from 'lodash'
|
import type { TemplateExecutor } from 'lodash'
|
||||||
|
|
||||||
import { Nuxt } from 'nuxt/core'
|
import { Nuxt } from 'src/core'
|
||||||
import { DeterminedGlobals, determineGlobals, isUrl } from 'nuxt/utils'
|
import { DeterminedGlobals, determineGlobals, isUrl } from 'src/utils'
|
||||||
import { VueRenderer } from 'nuxt/vue-renderer'
|
import { VueRenderer } from 'src/vue-renderer'
|
||||||
|
|
||||||
import ServerContext from './context'
|
import ServerContext from './context'
|
||||||
import renderAndGetWindow from './jsdom'
|
import renderAndGetWindow from './jsdom'
|
||||||
@ -347,12 +347,12 @@ export default class Server {
|
|||||||
return this.app.stack.map(({ handle }) => handle._middleware && handle._middleware.entry).filter(Boolean)
|
return this.app.stack.map(({ handle }) => handle._middleware && handle._middleware.entry).filter(Boolean)
|
||||||
}
|
}
|
||||||
|
|
||||||
renderRoute (...args: Parameters<VueRenderer['renderRoute']>) {
|
renderRoute () {
|
||||||
return this.renderer.renderRoute.apply(this.renderer, ...args.slice())
|
return this.renderer.renderRoute.apply(this.renderer, arguments)
|
||||||
}
|
}
|
||||||
|
|
||||||
loadResources (...args: Parameters<VueRenderer['loadResources']>) {
|
loadResources () {
|
||||||
return this.renderer.loadResources.apply(this.renderer, ...args)
|
return this.renderer.loadResources.apply(this.renderer, arguments)
|
||||||
}
|
}
|
||||||
|
|
||||||
renderAndGetWindow (url, opts = {}, {
|
renderAndGetWindow (url, opts = {}, {
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
<template>
|
|
||||||
Has pages/ ? <nuxt-page />
|
|
||||||
Please create `pages/index.vue` or `app.vue`
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div>
|
|
||||||
<nav>My navbar</nav>
|
|
||||||
<nuxt-page />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
/*
|
|
||||||
my-project/app.vue -> no router needed
|
|
||||||
|
|
||||||
vs
|
|
||||||
|
|
||||||
my-project/pages/index.vue -> router needed and app.vue display
|
|
||||||
|
|
||||||
vue-app/dotnuxt/app.vue
|
|
||||||
|
|
||||||
Resolving App:
|
|
||||||
1. ~/app.vue (variable)
|
|
||||||
2. (if pages/) nuxt-app/app.pages.vue (Light with router)
|
|
||||||
3. nuxt-app/app.tutorial.vue
|
|
||||||
|
|
||||||
For layers:
|
|
||||||
create {srcDir}/app.vue:
|
|
||||||
<template>
|
|
||||||
<nuxt-layer>
|
|
||||||
|
|
||||||
app.starter.vue -- guiding to create app.vue or pages/
|
|
||||||
app.default.vue if (pages/)
|
|
||||||
app.layout.vue if (layouts/)
|
|
||||||
|
|
||||||
pages/index.vue:
|
|
||||||
<nuxt-layout>
|
|
||||||
...
|
|
||||||
</nuxt-layout>
|
|
||||||
|
|
||||||
pages/about.vue:
|
|
||||||
...
|
|
||||||
|
|
||||||
*/
|
|
||||||
</script>
|
|
@ -1 +0,0 @@
|
|||||||
// nothing here
|
|
@ -1,10 +0,0 @@
|
|||||||
declare module NodeJS {
|
|
||||||
interface Process {
|
|
||||||
browser: boolean
|
|
||||||
client: boolean
|
|
||||||
mode: 'spa' | 'universal'
|
|
||||||
modern: boolean
|
|
||||||
server: boolean
|
|
||||||
static: boolean
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
declare module 'nuxt-build/routes' {
|
|
||||||
import { RouteRecordRaw } from 'vue-router'
|
|
||||||
|
|
||||||
const _default: RouteRecordRaw[]
|
|
||||||
export default _default
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
interface Window {
|
|
||||||
__NUXT__?: Record<string, any>
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
export { init } from './nuxt'
|
|
@ -1,54 +0,0 @@
|
|||||||
import type { IncomingMessage, ServerResponse } from 'http'
|
|
||||||
import Hookable from 'hookable'
|
|
||||||
import type { App } from 'vue'
|
|
||||||
|
|
||||||
import type { Plugin } from './types'
|
|
||||||
import { defineGetter } from './utils'
|
|
||||||
|
|
||||||
export class Nuxt extends Hookable {
|
|
||||||
app: App<Element>
|
|
||||||
ssrContext?: Record<string, any>
|
|
||||||
globalName: string
|
|
||||||
context: {
|
|
||||||
req?: IncomingMessage
|
|
||||||
res?: ServerResponse
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor ({ app, ssrContext, globalName }: { app: Nuxt['app'], ssrContext?: Nuxt['ssrContext'], globalName: Nuxt['globalName'] }) {
|
|
||||||
super()
|
|
||||||
this.app = app
|
|
||||||
this.ssrContext = ssrContext
|
|
||||||
this.globalName = globalName
|
|
||||||
}
|
|
||||||
|
|
||||||
provide (name: string, value: any) {
|
|
||||||
const $name = '$' + name
|
|
||||||
defineGetter(this.app, $name, value)
|
|
||||||
defineGetter(this.app.config.globalProperties, $name, value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface InitOptions {
|
|
||||||
app: Nuxt['app']
|
|
||||||
plugins?: Plugin[]
|
|
||||||
ssrContext?: Nuxt['ssrContext']
|
|
||||||
globalName?: Nuxt['globalName']
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function init ({ app, plugins, ssrContext, globalName = 'nuxt' }: InitOptions) {
|
|
||||||
const nuxt = new Nuxt({ app, ssrContext, globalName })
|
|
||||||
nuxt.provide('nuxt', nuxt)
|
|
||||||
|
|
||||||
const inject: Nuxt['provide'] = nuxt.provide.bind(nuxt)
|
|
||||||
|
|
||||||
for (const plugin of plugins) {
|
|
||||||
await plugin(nuxt, inject)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
declare module 'vue' {
|
|
||||||
interface App {
|
|
||||||
$nuxt: Nuxt
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
import { createSSRApp } from 'vue'
|
|
||||||
import { init } from 'nuxt-app'
|
|
||||||
import plugins from './plugins.client'
|
|
||||||
import App from '<%= appPath %>'
|
|
||||||
|
|
||||||
async function initApp () {
|
|
||||||
const app = createSSRApp(App)
|
|
||||||
|
|
||||||
await init({
|
|
||||||
app,
|
|
||||||
plugins
|
|
||||||
})
|
|
||||||
|
|
||||||
await app.$nuxt.callHook('client:create')
|
|
||||||
|
|
||||||
app.mount('#__nuxt')
|
|
||||||
|
|
||||||
await app.$nuxt.callHook('client:mounted')
|
|
||||||
|
|
||||||
console.log('App ready:', app) // eslint-disable-line no-console
|
|
||||||
}
|
|
||||||
|
|
||||||
initApp().catch((error) => {
|
|
||||||
console.error('Error while mounting app:', error) // eslint-disable-line no-console
|
|
||||||
})
|
|
@ -1,19 +0,0 @@
|
|||||||
import { createApp } from 'vue'
|
|
||||||
|
|
||||||
import { init } from 'nuxt-app'
|
|
||||||
import plugins from 'nuxt-build/plugins.server'
|
|
||||||
import App from '<%= appPath %>'
|
|
||||||
|
|
||||||
export default async function createNuxtAppServer (ssrContext = {}) {
|
|
||||||
const app = createApp(App)
|
|
||||||
|
|
||||||
await init({
|
|
||||||
app,
|
|
||||||
plugins,
|
|
||||||
ssrContext
|
|
||||||
})
|
|
||||||
|
|
||||||
await app.$nuxt.callHook('server:create')
|
|
||||||
|
|
||||||
return app
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
<template>
|
|
||||||
<Nuxt />
|
|
||||||
</template>
|
|
@ -1,5 +0,0 @@
|
|||||||
import sharedPlugins from './plugins'
|
|
||||||
|
|
||||||
export default [
|
|
||||||
...sharedPlugins
|
|
||||||
]
|
|
@ -1,7 +0,0 @@
|
|||||||
import preload from 'nuxt-app/plugins/preload'
|
|
||||||
import sharedPlugins from './plugins'
|
|
||||||
|
|
||||||
export default [
|
|
||||||
...sharedPlugins,
|
|
||||||
preload
|
|
||||||
]
|
|
@ -1,11 +0,0 @@
|
|||||||
// import router from 'nuxt-app/plugins/router'
|
|
||||||
import state from 'nuxt-app/plugins/state'
|
|
||||||
import components from 'nuxt-app/plugins/components'
|
|
||||||
import legacy from 'nuxt-app/plugins/legacy'
|
|
||||||
|
|
||||||
export default [
|
|
||||||
// router,
|
|
||||||
state,
|
|
||||||
components,
|
|
||||||
legacy
|
|
||||||
]
|
|
@ -1,19 +0,0 @@
|
|||||||
const Index = () => import('~/pages' /* webpackChunkName: "Home" */)
|
|
||||||
const About = () => import('~/pages/about' /* webpackChunkName: "About" */)
|
|
||||||
const Custom = () => import('~/pages/custom' /* webpackChunkName: "Custom" */)
|
|
||||||
|
|
||||||
export default [
|
|
||||||
{
|
|
||||||
path: '',
|
|
||||||
__file: '@/pages/index.vue',
|
|
||||||
component: Index
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/about',
|
|
||||||
component: About
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/custom',
|
|
||||||
component: Custom
|
|
||||||
}
|
|
||||||
]
|
|
@ -1,9 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html {{ HTML_ATTRS }}>
|
|
||||||
<head {{ HEAD_ATTRS }}>
|
|
||||||
{{ HEAD }}
|
|
||||||
</head>
|
|
||||||
<body {{ BODY_ATTRS }}>
|
|
||||||
<div id="__nuxt">{{ APP }}</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,23 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Server error</title>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" name=viewport>
|
|
||||||
<style>
|
|
||||||
.__nuxt-error-page{padding: 1rem;background:#f7f8fb;color:#47494e;text-align:center;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;font-family:sans-serif;font-weight:100!important;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;-webkit-font-smoothing:antialiased;position:absolute;top:0;left:0;right:0;bottom:0}.__nuxt-error-page .error{max-width:450px}.__nuxt-error-page .title{font-size:24px;font-size:1.5rem;margin-top:15px;color:#47494e;margin-bottom:8px}.__nuxt-error-page .description{color:#7f828b;line-height:21px;margin-bottom:10px}.__nuxt-error-page a{color:#7f828b!important;text-decoration:none}.__nuxt-error-page .logo{position:fixed;left:12px;bottom:12px}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="__nuxt-error-page">
|
|
||||||
<div class="error">
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="90" height="90" fill="#DBE1EC" viewBox="0 0 48 48"><path d="M22 30h4v4h-4zm0-16h4v12h-4zm1.99-10C12.94 4 4 12.95 4 24s8.94 20 19.99 20S44 35.05 44 24 35.04 4 23.99 4zM24 40c-8.84 0-16-7.16-16-16S15.16 8 24 8s16 7.16 16 16-7.16 16-16 16z"/></svg>
|
|
||||||
<div class="title">Server error</div>
|
|
||||||
<div class="description">{{ message }}</div>
|
|
||||||
</div>
|
|
||||||
<div class="logo">
|
|
||||||
<a href="https://nuxtjs.org" target="_blank" rel="noopener">Nuxt.js</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,15 +0,0 @@
|
|||||||
import type { Plugin } from 'nuxt/vue-app/types'
|
|
||||||
|
|
||||||
// import { h, defineComponent } from 'vue'
|
|
||||||
import { RouterLink } from 'vue-router'
|
|
||||||
|
|
||||||
// const NuxtLink = defineComponent({
|
|
||||||
// extends: Link
|
|
||||||
// })
|
|
||||||
|
|
||||||
const components: Plugin = function ({ app }) {
|
|
||||||
app.component('NuxtLink', RouterLink)
|
|
||||||
app.component('NLink', RouterLink) // TODO: deprecate
|
|
||||||
}
|
|
||||||
|
|
||||||
export default components
|
|
@ -1,20 +0,0 @@
|
|||||||
import type { App } from 'vue'
|
|
||||||
import type { Plugin } from 'nuxt/vue-app/types'
|
|
||||||
|
|
||||||
const legacy: Plugin = function ({ app }) {
|
|
||||||
app.$nuxt.context = {}
|
|
||||||
|
|
||||||
if (process.client) {
|
|
||||||
const legacyApp: App<Element> & { $root?: App<Element> } = { ...app }
|
|
||||||
legacyApp.$root = legacyApp
|
|
||||||
window[app.$nuxt.globalName] = legacyApp
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.server) {
|
|
||||||
const { ssrContext } = app.$nuxt
|
|
||||||
app.$nuxt.context.req = ssrContext.req
|
|
||||||
app.$nuxt.context.res = ssrContext.res
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default legacy
|
|
@ -1,13 +0,0 @@
|
|||||||
import type { Plugin } from 'nuxt/vue-app/types'
|
|
||||||
|
|
||||||
const preload: Plugin = function ({ app }) {
|
|
||||||
app.mixin({
|
|
||||||
beforeCreate () {
|
|
||||||
const { _registeredComponents } = this.$nuxt.ssrContext
|
|
||||||
const { __moduleIdentifier } = this.$options
|
|
||||||
_registeredComponents.push(__moduleIdentifier)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export default preload
|
|
@ -1,41 +0,0 @@
|
|||||||
import { ref } from 'vue'
|
|
||||||
import { createRouter, createWebHistory, createMemoryHistory } from 'vue-router'
|
|
||||||
|
|
||||||
import type { Plugin } from 'nuxt/vue-app/types'
|
|
||||||
|
|
||||||
import routes from 'nuxt-build/routes'
|
|
||||||
|
|
||||||
const router: Plugin = function ({ app }) {
|
|
||||||
const routerHistory = process.client
|
|
||||||
? createWebHistory()
|
|
||||||
: createMemoryHistory()
|
|
||||||
|
|
||||||
const router = createRouter({
|
|
||||||
history: routerHistory,
|
|
||||||
routes
|
|
||||||
})
|
|
||||||
app.use(router)
|
|
||||||
|
|
||||||
const previousRoute = ref()
|
|
||||||
router.afterEach((to, from) => {
|
|
||||||
previousRoute.value = from
|
|
||||||
})
|
|
||||||
|
|
||||||
Object.defineProperty(app.config.globalProperties, 'previousRoute', {
|
|
||||||
get: () => previousRoute.value
|
|
||||||
})
|
|
||||||
|
|
||||||
if (process.server) {
|
|
||||||
app.$nuxt.hook('server:create', async () => {
|
|
||||||
router.push(app.$nuxt.ssrContext.url)
|
|
||||||
await router.isReady()
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
app.$nuxt.hook('client:create', async () => {
|
|
||||||
router.push(router.history.location.fullPath)
|
|
||||||
await router.isReady()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default router
|
|
@ -1,17 +0,0 @@
|
|||||||
import type { Plugin } from 'nuxt/vue-app/types'
|
|
||||||
|
|
||||||
const state: Plugin = function ({ app }) {
|
|
||||||
if (process.server) {
|
|
||||||
app.$nuxt.state = {
|
|
||||||
serverRendered: true
|
|
||||||
// data, fetch, vuex, etc.
|
|
||||||
}
|
|
||||||
app.$nuxt.ssrContext.nuxt = app.$nuxt.state
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.client) {
|
|
||||||
app.$nuxt.state = window.__NUXT__ || {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default state
|
|
@ -1,12 +0,0 @@
|
|||||||
import path from 'path'
|
|
||||||
import globby from 'globby'
|
|
||||||
|
|
||||||
const dir = path.join(__dirname, 'nuxt')
|
|
||||||
const files = globby.sync(path.join(dir, '/**'))
|
|
||||||
.map(f => f.replace(dir + path.sep, '')) // TODO: workaround
|
|
||||||
|
|
||||||
export default {
|
|
||||||
dependencies: {},
|
|
||||||
dir,
|
|
||||||
files
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
import type { Nuxt } from './nuxt';
|
|
||||||
|
|
||||||
export interface Plugin {
|
|
||||||
(nuxt: Nuxt, inject?: Nuxt['provide']): Promise<void> | void
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
export function defineGetter<K extends string | number | symbol, V> (obj: Record<K, V>, key: K, val: V) {
|
|
||||||
Object.defineProperty(obj, key, { get: () => val })
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
{
|
|
||||||
"nuxtChildKey": {
|
|
||||||
"description": "This prop will be set to <router-view/>, useful to make transitions inside a dynamic page and different route. Default: `$route.fullPath`"
|
|
||||||
},
|
|
||||||
"to": {
|
|
||||||
"description": "Denotes the target route of the link. When clicked, the value of the to prop will be passed to router.push() internally, so the value can be either a string or a location descriptor object."
|
|
||||||
},
|
|
||||||
"prefetch": {
|
|
||||||
"type": "boolean",
|
|
||||||
"description": "Prefetch route target (overrides router.prefetchLinks value in nuxt.config.js)."
|
|
||||||
},
|
|
||||||
"no-prefetch": {
|
|
||||||
"description": "Avoid prefetching route target."
|
|
||||||
},
|
|
||||||
"replace": {
|
|
||||||
"type": "boolean",
|
|
||||||
"description": "Setting replace prop will call router.replace() instead of router.push() when clicked, so the navigation will not leave a history record."
|
|
||||||
},
|
|
||||||
"append": {
|
|
||||||
"type": "boolean",
|
|
||||||
"description": "Setting append prop always appends the relative path to the current path. For example, assuming we are navigating from /a to a relative link b, without append we will end up at /b, but with append we will end up at /a/b."
|
|
||||||
},
|
|
||||||
"tag": {
|
|
||||||
"description": "Specify which tag to render to, and it will still listen to click events for navigation."
|
|
||||||
},
|
|
||||||
"active-class": {
|
|
||||||
"description": "Configure the active CSS class applied when the link is active."
|
|
||||||
},
|
|
||||||
"exact": {
|
|
||||||
"description": "The default active class matching behavior is inclusive match. For example, <router-link to=\"/a\"> will get this class applied as long as the current path starts with /a/ or is /a.\nOne consequence of this is that <router-link to=\"/\"> will be active for every route! To force the link into \"exact match mode\", use the exact prop: <router-link to=\"/\" exact>"
|
|
||||||
},
|
|
||||||
"event": {
|
|
||||||
"description": "Specify the event(s) that can trigger the link navigation."
|
|
||||||
},
|
|
||||||
"exact-active-class": {
|
|
||||||
"description": "Configure the active CSS class applied when the link is active with exact match. Note the default value can also be configured globally via the linkExactActiveClass router constructor option."
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
{
|
|
||||||
"nuxt": {
|
|
||||||
"attributes": [
|
|
||||||
"nuxtChildKey"
|
|
||||||
],
|
|
||||||
"description": "Component to render the current nuxt page."
|
|
||||||
},
|
|
||||||
"n-child": {
|
|
||||||
"description": "Component for displaying the children components in a nested route."
|
|
||||||
},
|
|
||||||
"nuxt-child": {
|
|
||||||
"description": "Component for displaying the children components in a nested route."
|
|
||||||
},
|
|
||||||
"n-link": {
|
|
||||||
"attributes": [
|
|
||||||
"to",
|
|
||||||
"replace",
|
|
||||||
"append",
|
|
||||||
"tag",
|
|
||||||
"active-class",
|
|
||||||
"exact",
|
|
||||||
"event",
|
|
||||||
"exact-active-class",
|
|
||||||
"prefetch",
|
|
||||||
"no-prefetch"
|
|
||||||
],
|
|
||||||
"description": "Component for navigating between Nuxt pages."
|
|
||||||
},
|
|
||||||
"nuxt-link": {
|
|
||||||
"attributes": [
|
|
||||||
"to",
|
|
||||||
"replace",
|
|
||||||
"append",
|
|
||||||
"tag",
|
|
||||||
"active-class",
|
|
||||||
"exact",
|
|
||||||
"event",
|
|
||||||
"exact-active-class",
|
|
||||||
"prefetch",
|
|
||||||
"no-prefetch"
|
|
||||||
],
|
|
||||||
"description": "Component for navigating between Nuxt pages."
|
|
||||||
},
|
|
||||||
"no-ssr": {
|
|
||||||
"description": "Component for excluding a part of your app from server-side rendering."
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,12 +2,12 @@ import path from 'path'
|
|||||||
import fs from 'fs-extra'
|
import fs from 'fs-extra'
|
||||||
import consola from 'consola'
|
import consola from 'consola'
|
||||||
import template from 'lodash/template'
|
import template from 'lodash/template'
|
||||||
import { TARGETS, isModernRequest, waitFor } from 'nuxt/utils'
|
import { TARGETS, isModernRequest, waitFor } from 'src/utils'
|
||||||
|
|
||||||
import SPARenderer from './renderers/spa'
|
import SPARenderer from './renderers/spa'
|
||||||
import SSRRenderer from './renderers/ssr'
|
import SSRRenderer from './renderers/ssr'
|
||||||
import ModernRenderer from './renderers/modern'
|
import ModernRenderer from './renderers/modern'
|
||||||
import ServerContext from 'nuxt/server/context'
|
import ServerContext from 'src/server/context'
|
||||||
|
|
||||||
export default class VueRenderer {
|
export default class VueRenderer {
|
||||||
__closed?: boolean
|
__closed?: boolean
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import ServerContext from 'nuxt/server/context'
|
import ServerContext from 'src/server/context'
|
||||||
import { isUrl, urlJoin, safariNoModuleFix } from 'nuxt/utils'
|
import { isUrl, urlJoin, safariNoModuleFix } from 'src/utils'
|
||||||
|
|
||||||
import SSRRenderer from './ssr'
|
import SSRRenderer from './ssr'
|
||||||
|
|
||||||
|
@ -3,9 +3,8 @@ import cloneDeep from 'lodash/cloneDeep'
|
|||||||
import VueMeta from 'vue-meta'
|
import VueMeta from 'vue-meta'
|
||||||
import LRU from 'lru-cache'
|
import LRU from 'lru-cache'
|
||||||
import devalue from '@nuxt/devalue'
|
import devalue from '@nuxt/devalue'
|
||||||
|
import { TARGETS, isModernRequest } from 'src/utils'
|
||||||
import { TARGETS, isModernRequest } from 'nuxt/utils'
|
import ServerContext from 'src/server/context'
|
||||||
import ServerContext from 'nuxt/server/context'
|
|
||||||
import BaseRenderer from './base'
|
import BaseRenderer from './base'
|
||||||
|
|
||||||
export default class SPARenderer extends BaseRenderer {
|
export default class SPARenderer extends BaseRenderer {
|
||||||
|
@ -3,11 +3,11 @@ import crypto from 'crypto'
|
|||||||
import { format } from 'util'
|
import { format } from 'util'
|
||||||
import fs from 'fs-extra'
|
import fs from 'fs-extra'
|
||||||
import consola from 'consola'
|
import consola from 'consola'
|
||||||
|
import { TARGETS, urlJoin } from 'src/utils'
|
||||||
import devalue from '@nuxt/devalue'
|
import devalue from '@nuxt/devalue'
|
||||||
import { createBundleRenderer } from 'vue-bundle-renderer'
|
import { createBundleRenderer } from 'vue-bundle-renderer'
|
||||||
|
|
||||||
import { TARGETS, urlJoin } from 'nuxt/utils'
|
import ServerContext from 'src/server/context'
|
||||||
import ServerContext from 'nuxt/server/context'
|
|
||||||
import BaseRenderer from './base'
|
import BaseRenderer from './base'
|
||||||
|
|
||||||
export default class SSRRenderer extends BaseRenderer {
|
export default class SSRRenderer extends BaseRenderer {
|
||||||
|
@ -6,7 +6,7 @@ import webpackDevMiddleware from 'webpack-dev-middleware'
|
|||||||
import webpackHotMiddleware from 'webpack-hot-middleware'
|
import webpackHotMiddleware from 'webpack-hot-middleware'
|
||||||
import consola from 'consola'
|
import consola from 'consola'
|
||||||
|
|
||||||
import { TARGETS, parallel, sequence, wrapArray, isModernRequest } from 'nuxt/utils'
|
import { TARGETS, parallel, sequence, wrapArray, isModernRequest } from 'src/utils'
|
||||||
import { createMFS } from './utils/mfs'
|
import { createMFS } from './utils/mfs'
|
||||||
|
|
||||||
import * as WebpackConfigs from './config'
|
import * as WebpackConfigs from './config'
|
||||||
|
@ -9,7 +9,7 @@ import TerserWebpackPlugin from 'terser-webpack-plugin'
|
|||||||
import WebpackBar from 'webpackbar'
|
import WebpackBar from 'webpackbar'
|
||||||
import env from 'std-env'
|
import env from 'std-env'
|
||||||
import semver from 'semver'
|
import semver from 'semver'
|
||||||
import { TARGETS, isUrl, urlJoin, getPKG } from 'nuxt/utils'
|
import { TARGETS, isUrl, urlJoin, getPKG } from 'src/utils'
|
||||||
import PerfLoader from '../utils/perf-loader'
|
import PerfLoader from '../utils/perf-loader'
|
||||||
import StyleLoader from '../utils/style-loader'
|
import StyleLoader from '../utils/style-loader'
|
||||||
import WarningIgnorePlugin from '../plugins/warning-ignore'
|
import WarningIgnorePlugin from '../plugins/warning-ignore'
|
||||||
@ -258,7 +258,7 @@ export default class WebpackBaseConfig {
|
|||||||
alias () {
|
alias () {
|
||||||
return {
|
return {
|
||||||
...this.buildContext.options.alias,
|
...this.buildContext.options.alias,
|
||||||
'nuxt-app': path.dirname(require.resolve('../../vue-app')),
|
'app': this.buildContext.options.appDir,
|
||||||
'nuxt-build': this.buildContext.options.buildDir,
|
'nuxt-build': this.buildContext.options.buildDir,
|
||||||
'vue-meta': require.resolve(`vue-meta${this.isServer ? '' : '/dist/vue-meta.esm.browser.js'}`)
|
'vue-meta': require.resolve(`vue-meta${this.isServer ? '' : '/dist/vue-meta.esm.browser.js'}`)
|
||||||
}
|
}
|
||||||
@ -304,7 +304,7 @@ export default class WebpackBaseConfig {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.m?jsx?$/i,
|
test: /\.m?[jt]sx?$/i,
|
||||||
exclude: (file) => {
|
exclude: (file) => {
|
||||||
file = file.split('node_modules', 2)[1]
|
file = file.split('node_modules', 2)[1]
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
import EventEmitter from 'events'
|
import EventEmitter from 'events'
|
||||||
import HtmlWebpackPlugin from 'html-webpack-plugin'
|
import HtmlWebpackPlugin from 'html-webpack-plugin'
|
||||||
import { safariNoModuleFix } from 'nuxt/utils'
|
import { safariNoModuleFix } from 'src/utils'
|
||||||
|
|
||||||
const assetsMap = {}
|
const assetsMap = {}
|
||||||
const watcher = new EventEmitter()
|
const watcher = new EventEmitter()
|
||||||
|
@ -6,7 +6,7 @@ import merge from 'lodash/merge'
|
|||||||
import cloneDeep from 'lodash/cloneDeep'
|
import cloneDeep from 'lodash/cloneDeep'
|
||||||
import createResolver from 'postcss-import-resolver'
|
import createResolver from 'postcss-import-resolver'
|
||||||
|
|
||||||
import { isPureObject } from 'nuxt/utils'
|
import { isPureObject } from 'src/utils'
|
||||||
|
|
||||||
export const orderPresets = {
|
export const orderPresets = {
|
||||||
cssnanoLast (names) {
|
cssnanoLast (names) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import ExtractCssChunksPlugin from 'extract-css-chunks-webpack-plugin'
|
import ExtractCssChunksPlugin from 'extract-css-chunks-webpack-plugin'
|
||||||
|
|
||||||
import { wrapArray } from 'nuxt/utils'
|
import { wrapArray } from 'src/utils'
|
||||||
|
|
||||||
import PostcssConfig from './postcss'
|
import PostcssConfig from './postcss'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user