mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
feat: shared logger and silent test logs (#3259)
Co-authored-by: pooya parsa <pyapar@gmail.com>
This commit is contained in:
parent
ad52b795e2
commit
467ab693b9
@ -29,7 +29,6 @@
|
||||
"@vue/composition-api": "^1.4.6",
|
||||
"@vueuse/head": "^0.7.5",
|
||||
"acorn": "^8.7.0",
|
||||
"consola": "^2.15.3",
|
||||
"cookie-es": "^0.5.0",
|
||||
"defu": "^5.0.1",
|
||||
"destr": "^1.1.0",
|
||||
|
@ -2,7 +2,7 @@ import { resolve } from 'pathe'
|
||||
import * as vite from 'vite'
|
||||
import { createVuePlugin } from 'vite-plugin-vue2'
|
||||
import PluginLegacy from '@vitejs/plugin-legacy'
|
||||
import consola from 'consola'
|
||||
import { logger } from '@nuxt/kit'
|
||||
import { joinURL } from 'ufo'
|
||||
import { devStyleSSRPlugin } from '../../../vite/src/plugins/dev-ssr-css'
|
||||
import { jsxPlugin } from './plugins/jsx'
|
||||
@ -54,9 +54,9 @@ export async function buildClient (ctx: ViteBuildContext) {
|
||||
// Production build
|
||||
if (!ctx.nuxt.options.dev) {
|
||||
const start = Date.now()
|
||||
consola.info('Building client...')
|
||||
logger.info('Building client...')
|
||||
await vite.build(clientConfig)
|
||||
consola.success(`Client built in ${Date.now() - start}ms`)
|
||||
logger.success(`Client built in ${Date.now() - start}ms`)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
import consola from 'consola'
|
||||
import { addPluginTemplate, defineNuxtModule } from '@nuxt/kit'
|
||||
import { logger, addPluginTemplate, defineNuxtModule } from '@nuxt/kit'
|
||||
import { version } from '../../package.json'
|
||||
import { middlewareTemplate, storeTemplate } from './templates'
|
||||
import type { ViteOptions } from './types'
|
||||
@ -15,9 +14,9 @@ export default defineNuxtModule<ViteOptions>({
|
||||
nuxt.options.cli.badgeMessages.push(`⚡ Vite Mode Enabled (v${version})`)
|
||||
// eslint-disable-next-line no-console
|
||||
if (viteOptions.experimentWarning !== false && !nuxt.options.test) {
|
||||
consola.log(
|
||||
logger.log(
|
||||
'🧪 Vite mode is experimental and some nuxt modules might be incompatible\n',
|
||||
' If found a bug, please report via https://github.com/nuxt/vite/issues with a minimal reproduction.'
|
||||
' If found a bug, please report via https://github.com/nuxt/framework/issues with a minimal reproduction.'
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { resolve } from 'pathe'
|
||||
import * as vite from 'vite'
|
||||
import { createVuePlugin } from 'vite-plugin-vue2'
|
||||
import consola from 'consola'
|
||||
import { logger } from '@nuxt/kit'
|
||||
import fse from 'fs-extra'
|
||||
import pDebounce from 'p-debounce'
|
||||
import { bundleRequest } from '../../../vite/src/dev-bundler'
|
||||
@ -80,10 +80,10 @@ export async function buildServer (ctx: ViteBuildContext) {
|
||||
// Production build
|
||||
if (!ctx.nuxt.options.dev) {
|
||||
const start = Date.now()
|
||||
consola.info('Building server...')
|
||||
logger.info('Building server...')
|
||||
await vite.build(serverConfig)
|
||||
await onBuild()
|
||||
consola.success(`Server built in ${Date.now() - start}ms`)
|
||||
logger.success(`Server built in ${Date.now() - start}ms`)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { resolve } from 'pathe'
|
||||
import * as vite from 'vite'
|
||||
import consola from 'consola'
|
||||
import { logger } from '@nuxt/kit'
|
||||
import { withoutLeadingSlash } from 'ufo'
|
||||
import { distDir } from '../dirs'
|
||||
import { warmupViteServer } from '../../../vite/src/utils/warmup'
|
||||
@ -95,8 +95,8 @@ async function bundle (nuxt: Nuxt, builder: any) {
|
||||
ctx.nuxt.hook('vite:serverCreated', (server: vite.ViteDevServer) => {
|
||||
const start = Date.now()
|
||||
warmupViteServer(server, ['/.nuxt/entry.mjs']).then(() => {
|
||||
consola.info(`Vite warmed up in ${Date.now() - start}ms`)
|
||||
}).catch(consola.error)
|
||||
logger.info(`Vite warmed up in ${Date.now() - start}ms`)
|
||||
}).catch(logger.error)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ export * from './plugin'
|
||||
export * from './resolve'
|
||||
export * from './server'
|
||||
export * from './template'
|
||||
export * from './logger'
|
||||
|
||||
// Internal Utils
|
||||
// TODO
|
||||
|
7
packages/kit/src/logger.ts
Normal file
7
packages/kit/src/logger.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import consola from 'consola'
|
||||
|
||||
export const logger = consola
|
||||
|
||||
export function useLogger (scope?: string) {
|
||||
return scope ? logger.withScope(scope) : logger
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
import { parse, relative } from 'pathe'
|
||||
import consola from 'consola'
|
||||
import type { Nuxt, NuxtPluginTemplate, NuxtTemplate, ModuleContainer } from '@nuxt/schema'
|
||||
import { logger } from '../logger'
|
||||
import { chainFn } from '../internal/task'
|
||||
import { addTemplate } from '../template'
|
||||
import { addServerMiddleware } from '../server'
|
||||
@ -67,7 +67,7 @@ export function useModuleContainer (nuxt: Nuxt = useNuxt()): ModuleContainer {
|
||||
const layout = nuxt.options.layouts[layoutName]
|
||||
|
||||
if (layout) {
|
||||
consola.warn(`Duplicate layout registration, "${layoutName}" has been registered as "${layout}"`)
|
||||
logger.warn(`Duplicate layout registration, "${layoutName}" has been registered as "${layout}"`)
|
||||
}
|
||||
nuxt.options.layouts[layoutName] = `./${filename}`
|
||||
if (name === 'error') {
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { promises as fsp } from 'fs'
|
||||
import defu from 'defu'
|
||||
import { applyDefaults } from 'untyped'
|
||||
import consola from 'consola'
|
||||
import { dirname } from 'pathe'
|
||||
import type { Nuxt, NuxtTemplate, NuxtModule, ModuleOptions, ModuleDefinition } from '@nuxt/schema'
|
||||
import { logger } from '../logger'
|
||||
import { useNuxt, nuxtCtx } from '../context'
|
||||
import { isNuxt2, checkNuxtCompatibility } from '../compatibility'
|
||||
import { templateUtils, compileTemplate } from '../internal/template'
|
||||
@ -17,7 +17,7 @@ export function defineNuxtModule<OptionsT extends ModuleOptions> (definition: Mo
|
||||
if (typeof definition === 'function') {
|
||||
// @ts-ignore
|
||||
definition = definition(useNuxt())
|
||||
consola.warn('Module definition as function is deprecated and will be removed in the future versions', definition)
|
||||
logger.warn('Module definition as function is deprecated and will be removed in the future versions', definition)
|
||||
}
|
||||
|
||||
// Normalize definition and meta
|
||||
@ -57,11 +57,11 @@ export function defineNuxtModule<OptionsT extends ModuleOptions> (definition: Mo
|
||||
nuxt.options._requiredModules[uniqueKey] = true
|
||||
}
|
||||
|
||||
// Check compatibility contraints
|
||||
// Check compatibility constraints
|
||||
if (definition.meta.compatibility) {
|
||||
const issues = await checkNuxtCompatibility(definition.meta.compatibility, nuxt)
|
||||
if (issues.length) {
|
||||
consola.warn(`Module \`${definition.meta.name}\` is disabled due to incompatibility issues:\n${issues.toString()}`)
|
||||
logger.warn(`Module \`${definition.meta.name}\` is disabled due to incompatibility issues:\n${issues.toString()}`)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { relative, resolve, join } from 'pathe'
|
||||
import consola from 'consola'
|
||||
import { logger } from '@nuxt/kit'
|
||||
import * as rollup from 'rollup'
|
||||
import fse from 'fs-extra'
|
||||
import { genDynamicImport } from 'knitwork'
|
||||
@ -10,7 +10,7 @@ import { NitroContext } from './context'
|
||||
import { scanMiddleware } from './server/middleware'
|
||||
|
||||
export async function prepare (nitroContext: NitroContext) {
|
||||
consola.info(`Nitro preset is ${hl(nitroContext.preset)}`)
|
||||
logger.info(`Nitro preset is ${hl(nitroContext.preset)}`)
|
||||
|
||||
await cleanupDir(nitroContext.output.dir)
|
||||
|
||||
@ -24,12 +24,12 @@ export async function prepare (nitroContext: NitroContext) {
|
||||
}
|
||||
|
||||
async function cleanupDir (dir: string) {
|
||||
consola.info('Cleaning up', prettyPath(dir))
|
||||
logger.info('Cleaning up', prettyPath(dir))
|
||||
await fse.emptyDir(dir)
|
||||
}
|
||||
|
||||
export async function generate (nitroContext: NitroContext) {
|
||||
consola.start('Generating public...')
|
||||
logger.start('Generating public...')
|
||||
|
||||
await nitroContext._internal.hooks.callHook('nitro:generate', nitroContext)
|
||||
|
||||
@ -44,7 +44,7 @@ export async function generate (nitroContext: NitroContext) {
|
||||
await fse.copy(clientDist, buildAssetsDir)
|
||||
}
|
||||
|
||||
consola.success('Generated public ' + prettyPath(nitroContext.output.publicDir))
|
||||
logger.success('Generated public ' + prettyPath(nitroContext.output.publicDir))
|
||||
}
|
||||
|
||||
export async function build (nitroContext: NitroContext) {
|
||||
@ -96,13 +96,13 @@ async function _build (nitroContext: NitroContext) {
|
||||
nitroContext.scannedMiddleware = await scanMiddleware(nitroContext._nuxt.serverDir)
|
||||
await writeTypes(nitroContext)
|
||||
|
||||
consola.start('Building server...')
|
||||
logger.start('Building server...')
|
||||
const build = await rollup.rollup(nitroContext.rollupConfig).catch((error) => {
|
||||
consola.error('Rollup error: ' + error.message)
|
||||
logger.error('Rollup error: ' + error.message)
|
||||
throw error
|
||||
})
|
||||
|
||||
consola.start('Writing server bundle...')
|
||||
logger.start('Writing server bundle...')
|
||||
await build.write(nitroContext.rollupConfig.output)
|
||||
|
||||
const rewriteBuildPaths = (input: unknown, to: string) =>
|
||||
@ -120,7 +120,7 @@ async function _build (nitroContext: NitroContext) {
|
||||
}
|
||||
await writeFile(nitroConfigPath, JSON.stringify(buildInfo, null, 2))
|
||||
|
||||
consola.success('Server built')
|
||||
logger.success('Server built')
|
||||
await printFSTree(nitroContext.output.serverDir)
|
||||
await nitroContext._internal.hooks.callHook('nitro:compiled', nitroContext)
|
||||
|
||||
@ -128,10 +128,10 @@ async function _build (nitroContext: NitroContext) {
|
||||
const rOutDir = relative(process.cwd(), nitroContext.output.dir)
|
||||
if (nitroContext.commands.preview) {
|
||||
// consola.info(`You can preview this build using \`${rewriteBuildPaths(nitroContext.commands.preview, rOutDir)}\``)
|
||||
consola.info('You can preview this build using `nuxi preview`')
|
||||
logger.info('You can preview this build using `nuxi preview`')
|
||||
}
|
||||
if (nitroContext.commands.deploy) {
|
||||
consola.info(`You can deploy this build using \`${rewriteBuildPaths(nitroContext.commands.deploy, rOutDir)}\``)
|
||||
logger.info(`You can deploy this build using \`${rewriteBuildPaths(nitroContext.commands.deploy, rOutDir)}\``)
|
||||
}
|
||||
|
||||
return {
|
||||
@ -157,12 +157,12 @@ function startRollupWatcher (nitroContext: NitroContext) {
|
||||
// Finished building all bundles
|
||||
case 'END':
|
||||
nitroContext._internal.hooks.callHook('nitro:compiled', nitroContext)
|
||||
consola.success('Nitro built', start ? `in ${Date.now() - start} ms` : '')
|
||||
logger.success('Nitro built', start ? `in ${Date.now() - start} ms` : '')
|
||||
return
|
||||
|
||||
// Encountered an error while bundling
|
||||
case 'ERROR':
|
||||
consola.error('Rollup error: ' + event.error)
|
||||
logger.error('Rollup error: ' + event.error)
|
||||
// consola.error(event.error)
|
||||
}
|
||||
})
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { existsSync, promises as fsp } from 'fs'
|
||||
import { resolve } from 'pathe'
|
||||
import consola from 'consola'
|
||||
import { logger } from '@nuxt/kit'
|
||||
import { joinURL } from 'ufo'
|
||||
import { genString } from 'knitwork'
|
||||
import { extendPreset, prettyPath } from '../utils'
|
||||
@ -77,7 +77,7 @@ if ('serviceWorker' in navigator) {
|
||||
if (!existsSync(resolve(output.publicDir, '404.html'))) {
|
||||
await fsp.writeFile(resolve(output.publicDir, '404.html'), html, 'utf8')
|
||||
}
|
||||
consola.info('Ready to deploy to static hosting:', prettyPath(output.publicDir as string))
|
||||
logger.info('Ready to deploy to static hosting:', prettyPath(output.publicDir as string))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { resolve } from 'pathe'
|
||||
import consola from 'consola'
|
||||
|
||||
import { writeTypes } from '../utils/prepare'
|
||||
import { loadKit } from '../utils/kit'
|
||||
import { clearDir } from '../utils/fs'
|
||||
|
@ -29,7 +29,6 @@
|
||||
"@vue/shared": "^3.2.31",
|
||||
"@vueuse/head": "^0.7.5",
|
||||
"chokidar": "^3.5.3",
|
||||
"consola": "^2.15.3",
|
||||
"cookie-es": "^0.5.0",
|
||||
"defu": "^5.0.1",
|
||||
"destr": "^1.1.0",
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { createRequire } from 'module'
|
||||
import { createUnplugin } from 'unplugin'
|
||||
import consola from 'consola'
|
||||
import { logger } from '@nuxt/kit'
|
||||
import { isAbsolute, relative, resolve } from 'pathe'
|
||||
import type { Nuxt } from '@nuxt/schema'
|
||||
import escapeRE from 'escape-string-regexp'
|
||||
@ -40,7 +40,7 @@ export const ImportProtectionPlugin = createUnplugin(function (options: ImportPr
|
||||
if (cache[id].has(pattern)) { continue }
|
||||
|
||||
const relativeImporter = isAbsolute(importer) ? relative(options.rootDir, importer) : importer
|
||||
consola.error(warning || 'Invalid import', `[importing \`${id}\` from \`${relativeImporter}\`]`)
|
||||
logger.error(warning || 'Invalid import', `[importing \`${id}\` from \`${relativeImporter}\`]`)
|
||||
cache[id].set(pattern, true)
|
||||
matched = true
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ export default defineBuildConfig({
|
||||
'webpack-bundle-analyzer',
|
||||
'rollup-plugin-visualizer',
|
||||
'vite',
|
||||
'consola',
|
||||
// Implicit
|
||||
'@vue/compiler-core',
|
||||
'@vue/shared'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { join, resolve } from 'pathe'
|
||||
import { isDevelopment } from 'std-env'
|
||||
import { isDevelopment, isTest } from 'std-env'
|
||||
import createRequire from 'create-require'
|
||||
import { pascalCase } from 'scule'
|
||||
import jiti from 'jiti'
|
||||
@ -7,7 +7,7 @@ import defu from 'defu'
|
||||
|
||||
export default {
|
||||
/**
|
||||
* Extend nested configurations from multiple local or remoted sources
|
||||
* Extend nested configurations from multiple local or remote sources
|
||||
*
|
||||
* Value should be either a string or array of strings pointing to source directories or config path relative to current config.
|
||||
*
|
||||
@ -738,5 +738,5 @@ export default {
|
||||
*/
|
||||
publicRuntimeConfig: {
|
||||
$resolve: (val: Record<string, any> = {}, get) => ({ ...val, app: defu(val.app, get('app')) })
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -58,4 +58,4 @@ export interface NuxtApp {
|
||||
}
|
||||
|
||||
type _TemplatePlugin = NuxtPlugin & NuxtTemplate
|
||||
export interface NuxtPluginTemplate extends _TemplatePlugin {}
|
||||
export interface NuxtPluginTemplate extends _TemplatePlugin { }
|
||||
|
@ -10,6 +10,7 @@ export function createTestContext (options: Partial<TestOptions>): TestContext {
|
||||
fixture: 'fixture',
|
||||
configFile: 'nuxt.config',
|
||||
setupTimeout: 60000,
|
||||
logLevel: 1,
|
||||
server: options.browser,
|
||||
build: options.browser || options.server,
|
||||
nuxtConfig: {},
|
||||
|
@ -54,6 +54,8 @@ export async function loadFixture () {
|
||||
configFile: ctx.options.configFile
|
||||
})
|
||||
|
||||
kit.logger.level = ctx.options.logLevel
|
||||
|
||||
await fsp.mkdir(ctx.nuxt.options.buildDir, { recursive: true })
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ export interface TestOptions {
|
||||
waitFor: number
|
||||
browser: boolean
|
||||
runner: TestRunner
|
||||
logLevel: number
|
||||
browserOptions: {
|
||||
type: 'chromium' | 'firefox' | 'webkit'
|
||||
launch?: LaunchOptions
|
||||
|
@ -23,7 +23,6 @@
|
||||
"@vitejs/plugin-vue-jsx": "^1.3.7",
|
||||
"autoprefixer": "^10.4.2",
|
||||
"chokidar": "^3.5.3",
|
||||
"consola": "^2.15.3",
|
||||
"defu": "^5.0.1",
|
||||
"esbuild": "^0.14.21",
|
||||
"escape-string-regexp": "^5.0.0",
|
||||
|
@ -1,10 +1,9 @@
|
||||
import { resolve } from 'pathe'
|
||||
import * as vite from 'vite'
|
||||
import consola from 'consola'
|
||||
import vuePlugin from '@vitejs/plugin-vue'
|
||||
import viteJsxPlugin from '@vitejs/plugin-vue-jsx'
|
||||
import type { Connect } from 'vite'
|
||||
|
||||
import { logger } from '@nuxt/kit'
|
||||
import { joinURL } from 'ufo'
|
||||
import { cacheDirPlugin } from './plugins/cache-dir'
|
||||
import { analyzePlugin } from './plugins/analyze'
|
||||
@ -80,7 +79,7 @@ export async function buildClient (ctx: ViteBuildContext) {
|
||||
const start = Date.now()
|
||||
await vite.build(clientConfig)
|
||||
await ctx.nuxt.callHook('build:resources', wpfs)
|
||||
consola.info(`Client built in ${Date.now() - start}ms`)
|
||||
logger.info(`Client built in ${Date.now() - start}ms`)
|
||||
}
|
||||
|
||||
await writeManifest(ctx)
|
||||
|
@ -2,10 +2,9 @@ import { join, resolve, normalize } from 'pathe'
|
||||
import * as vite from 'vite'
|
||||
import vuePlugin from '@vitejs/plugin-vue'
|
||||
import viteJsxPlugin from '@vitejs/plugin-vue-jsx'
|
||||
import { logger, resolveModule } from '@nuxt/kit'
|
||||
import fse from 'fs-extra'
|
||||
import pDebounce from 'p-debounce'
|
||||
import consola from 'consola'
|
||||
import { resolveModule } from '@nuxt/kit'
|
||||
import { withoutTrailingSlash } from 'ufo'
|
||||
import { ViteBuildContext, ViteOptions } from './vite'
|
||||
import { wpfs } from './utils/wpfs'
|
||||
@ -117,10 +116,10 @@ export async function buildServer (ctx: ViteBuildContext) {
|
||||
// Production build
|
||||
if (!ctx.nuxt.options.dev) {
|
||||
const start = Date.now()
|
||||
consola.info('Building server...')
|
||||
logger.info('Building server...')
|
||||
await vite.build(serverConfig)
|
||||
await onBuild()
|
||||
consola.success(`Server built in ${Date.now() - start}ms`)
|
||||
logger.success(`Server built in ${Date.now() - start}ms`)
|
||||
return
|
||||
}
|
||||
|
||||
@ -147,7 +146,7 @@ export async function buildServer (ctx: ViteBuildContext) {
|
||||
// Have CSS in the manifest to prevent FOUC on dev SSR
|
||||
await writeManifest(ctx, ids.filter(isCSS).map(i => i.slice(1)))
|
||||
const time = (Date.now() - start)
|
||||
consola.success(`Vite server built in ${time}ms`)
|
||||
logger.success(`Vite server built in ${time}ms`)
|
||||
await onBuild()
|
||||
}
|
||||
const doBuild = pDebounce(_doBuild, 100)
|
||||
|
@ -1,4 +1,4 @@
|
||||
import consola from 'consola'
|
||||
import { logger } from '@nuxt/kit'
|
||||
import type { ViteDevServer } from 'vite'
|
||||
|
||||
export async function warmupViteServer (server: ViteDevServer, entries: string[]) {
|
||||
@ -10,7 +10,7 @@ export async function warmupViteServer (server: ViteDevServer, entries: string[]
|
||||
try {
|
||||
await server.transformRequest(url)
|
||||
} catch (e) {
|
||||
consola.debug('Warmup for %s failed with: %s', url, e)
|
||||
logger.debug('Warmup for %s failed with: %s', url, e)
|
||||
}
|
||||
const deps = Array.from(server.moduleGraph.urlToModuleMap.get(url)?.importedModules || [])
|
||||
await Promise.all(deps.map(m => warmup(m.url)))
|
||||
|
@ -1,8 +1,8 @@
|
||||
import * as vite from 'vite'
|
||||
import { resolve } from 'pathe'
|
||||
import consola from 'consola'
|
||||
import type { Nuxt } from '@nuxt/schema'
|
||||
import type { InlineConfig, SSROptions } from 'vite'
|
||||
import { logger } from '@nuxt/kit'
|
||||
import type { Options } from '@vitejs/plugin-vue'
|
||||
import { sanitizeFilePath } from 'mlly'
|
||||
import { joinURL, withoutLeadingSlash } from 'ufo'
|
||||
@ -126,9 +126,9 @@ export async function bundle (nuxt: Nuxt) {
|
||||
})
|
||||
|
||||
const start = Date.now()
|
||||
warmupViteServer(server, ['/entry.mjs']).then(() => {
|
||||
consola.info(`Vite warmed up in ${Date.now() - start}ms`)
|
||||
}).catch(consola.error)
|
||||
warmupViteServer(server, ['/entry.mjs'])
|
||||
.then(() => logger.info(`Vite warmed up in ${Date.now() - start}ms`))
|
||||
.catch(logger.error)
|
||||
})
|
||||
|
||||
await buildClient(ctx)
|
||||
|
@ -22,7 +22,6 @@
|
||||
"@vue/babel-preset-jsx": "^1.2.4",
|
||||
"autoprefixer": "^10.4.2",
|
||||
"babel-loader": "^8.2.3",
|
||||
"consola": "^2.15.3",
|
||||
"css-loader": "^6.6.0",
|
||||
"css-minimizer-webpack-plugin": "^3.4.1",
|
||||
"cssnano": "^5.0.17",
|
||||
|
@ -3,15 +3,15 @@
|
||||
* https://github.com/vuejs/vue/blob/dev/src/server/webpack-plugin/util.js
|
||||
*/
|
||||
|
||||
import consola from 'consola'
|
||||
import { logger } from '@nuxt/kit'
|
||||
|
||||
export const validate = (compiler) => {
|
||||
if (compiler.options.target !== 'node') {
|
||||
consola.warn('webpack config `target` should be "node".')
|
||||
logger.warn('webpack config `target` should be "node".')
|
||||
}
|
||||
|
||||
if (!compiler.options.externals) {
|
||||
consola.info(
|
||||
logger.info(
|
||||
'It is recommended to externalize dependencies in the server build for ' +
|
||||
'better build performance.'
|
||||
)
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { resolve, normalize } from 'pathe'
|
||||
import TimeFixPlugin from 'time-fix-plugin'
|
||||
import WebpackBar from 'webpackbar'
|
||||
import consola from 'consola'
|
||||
import webpack from 'webpack'
|
||||
import { logger } from '@nuxt/kit'
|
||||
import FriendlyErrorsWebpackPlugin from '@nuxt/friendly-errors-webpack-plugin'
|
||||
import escapeRegExp from 'escape-string-regexp'
|
||||
import { joinURL } from 'ufo'
|
||||
@ -93,7 +93,7 @@ function basePlugins (ctx: WebpackConfigContext) {
|
||||
if (state.hasErrors) {
|
||||
nuxt.callHook('bundler:error')
|
||||
} else {
|
||||
consola.success(`${state.name} ${state.message}`)
|
||||
logger.success(`${state.name} ${state.message}`)
|
||||
}
|
||||
},
|
||||
allDone: () => {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import consola from 'consola'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import type { Configuration } from 'webpack'
|
||||
import type { Nuxt } from '@nuxt/schema'
|
||||
import { logger } from '@nuxt/kit'
|
||||
|
||||
export interface WebpackConfigContext extends ReturnType<typeof createWebpackConfigContext>{ }
|
||||
|
||||
@ -51,7 +51,7 @@ export function fileName (ctx: WebpackConfigContext, key: string) {
|
||||
if (typeof fileName === 'string' && options.dev) {
|
||||
const hash = /\[(chunkhash|contenthash|hash)(?::(\d+))?]/.exec(fileName)
|
||||
if (hash) {
|
||||
consola.warn(`Notice: Please do not use ${hash[1]} in dev mode to prevent memory leak`)
|
||||
logger.warn(`Notice: Please do not use ${hash[1]} in dev mode to prevent memory leak`)
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ export function getWebpackConfig (ctx: WebpackConfigContext): Configuration {
|
||||
const { devtool } = extendedConfig
|
||||
if (typeof devtool === 'string' && pragma.test(devtool)) {
|
||||
extendedConfig.devtool = devtool.replace(pragma, '')
|
||||
consola.warn(`devtool has been normalized to ${extendedConfig.devtool} as webpack documented value`)
|
||||
logger.warn(`devtool has been normalized to ${extendedConfig.devtool} as webpack documented value`)
|
||||
}
|
||||
|
||||
return extendedConfig
|
||||
|
@ -1,10 +1,9 @@
|
||||
import fs from 'fs'
|
||||
import { resolve } from 'pathe'
|
||||
import consola from 'consola'
|
||||
import { logger, requireModule } from '@nuxt/kit'
|
||||
import { createCommonJS } from 'mlly'
|
||||
import { defaults, merge, cloneDeep } from 'lodash-es'
|
||||
import createResolver from 'postcss-import-resolver'
|
||||
import { requireModule } from '@nuxt/kit'
|
||||
import type { Nuxt } from '@nuxt/schema'
|
||||
|
||||
const isPureObject = obj => obj !== null && !Array.isArray(obj) && typeof obj === 'object'
|
||||
@ -34,7 +33,7 @@ function postcssConfigFileWarning () {
|
||||
if (_postcssConfigFileWarningShown) {
|
||||
return
|
||||
}
|
||||
consola.warn('Please use `build.postcss` in your nuxt.config.js instead of an external config file. Support for such files will be removed in Nuxt 3 as they remove all defaults set by Nuxt and can cause severe problems with features like alias resolving inside your CSS.')
|
||||
logger.warn('Please use `build.postcss` in your nuxt.config.js instead of an external config file. Support for such files will be removed in Nuxt 3 as they remove all defaults set by Nuxt and can cause severe problems with features like alias resolving inside your CSS.')
|
||||
_postcssConfigFileWarningShown = true
|
||||
}
|
||||
|
||||
|
@ -6,8 +6,7 @@ import Glob from 'glob'
|
||||
import webpackDevMiddleware from 'webpack-dev-middleware'
|
||||
import webpackHotMiddleware from 'webpack-hot-middleware'
|
||||
import VirtualModulesPlugin from 'webpack-virtual-modules'
|
||||
import consola from 'consola'
|
||||
|
||||
import { logger } from '@nuxt/kit'
|
||||
import type { Compiler, Watching } from 'webpack'
|
||||
import type { Context as WebpackDevMiddlewareContext, Options as WebpackDevMiddlewareOptions } from 'webpack-dev-middleware'
|
||||
import type { MiddlewareOptions as WebpackHotMiddlewareOptions } from 'webpack-hot-middleware'
|
||||
@ -96,7 +95,7 @@ class WebpackBundler {
|
||||
// Check styleResource existence
|
||||
const { styleResources } = this.nuxt.options.build
|
||||
if (styleResources && Object.keys(styleResources).length) {
|
||||
consola.warn(
|
||||
logger.warn(
|
||||
'Using styleResources without the @nuxtjs/style-resources is not suggested and can lead to severe performance issues.',
|
||||
'Please use https://github.com/nuxt-community/style-resources-module'
|
||||
)
|
||||
@ -204,7 +203,7 @@ class WebpackBundler {
|
||||
}
|
||||
|
||||
async webpackDev (compiler: Compiler) {
|
||||
consola.debug('Creating webpack middleware...')
|
||||
logger.debug('Creating webpack middleware...')
|
||||
|
||||
const { name } = compiler.options
|
||||
const buildOptions = this.nuxt.options.build
|
||||
|
@ -2652,7 +2652,6 @@ __metadata:
|
||||
"@vue/composition-api": ^1.4.6
|
||||
"@vueuse/head": ^0.7.5
|
||||
acorn: ^8.7.0
|
||||
consola: ^2.15.3
|
||||
cookie-es: ^0.5.0
|
||||
defu: ^5.0.1
|
||||
destr: ^1.1.0
|
||||
@ -3359,7 +3358,6 @@ __metadata:
|
||||
"@vitejs/plugin-vue-jsx": ^1.3.7
|
||||
autoprefixer: ^10.4.2
|
||||
chokidar: ^3.5.3
|
||||
consola: ^2.15.3
|
||||
defu: ^5.0.1
|
||||
esbuild: ^0.14.21
|
||||
escape-string-regexp: ^5.0.0
|
||||
@ -3476,7 +3474,6 @@ __metadata:
|
||||
"@vue/babel-preset-jsx": ^1.2.4
|
||||
autoprefixer: ^10.4.2
|
||||
babel-loader: ^8.2.3
|
||||
consola: ^2.15.3
|
||||
css-loader: ^6.6.0
|
||||
css-minimizer-webpack-plugin: ^3.4.1
|
||||
cssnano: ^5.0.17
|
||||
@ -15385,7 +15382,6 @@ __metadata:
|
||||
"@vue/shared": ^3.2.31
|
||||
"@vueuse/head": ^0.7.5
|
||||
chokidar: ^3.5.3
|
||||
consola: ^2.15.3
|
||||
cookie-es: ^0.5.0
|
||||
defu: ^5.0.1
|
||||
destr: ^1.1.0
|
||||
|
Loading…
Reference in New Issue
Block a user