mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-20 07:30:57 +00:00
fix(config): add analyze plugin options in bridge mode (#3292)
This commit is contained in:
parent
070de5ba45
commit
48cc6086e4
@ -2,7 +2,7 @@ import { promises as fsp } from 'fs'
|
||||
import fetch from 'node-fetch'
|
||||
import { addPluginTemplate, useNuxt } from '@nuxt/kit'
|
||||
import { joinURL, stringifyQuery } from 'ufo'
|
||||
import { resolve } from 'pathe'
|
||||
import { resolve, join } from 'pathe'
|
||||
import { build, generate, prepare, getNitroContext, NitroContext, createDevServer, wpfs, resolveMiddleware, scanMiddleware, writeTypes } from '@nuxt/nitro'
|
||||
import { AsyncLoadingPlugin } from './async-loading'
|
||||
import { distDir } from './dirs'
|
||||
@ -29,6 +29,15 @@ export function setupNitroBridge () {
|
||||
// @ts-ignore
|
||||
nuxt.options.build.indicator = false
|
||||
|
||||
if (nuxt.options.build.analyze === true) {
|
||||
const { rootDir } = nuxt.options
|
||||
nuxt.options.build.analyze = {
|
||||
template: 'treemap',
|
||||
projectRoot: rootDir,
|
||||
filename: join(rootDir, '.nuxt/stats', '{name}.html')
|
||||
}
|
||||
}
|
||||
|
||||
// Create contexts
|
||||
const nitroOptions = (nuxt.options as any).nitro || {}
|
||||
const nitroContext = getNitroContext(nuxt.options, nitroOptions)
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { promises as fsp } from 'fs'
|
||||
import { join, resolve } from 'pathe'
|
||||
import { createApp, lazyHandle } from 'h3'
|
||||
import type { PluginVisualizerOptions } from 'rollup-plugin-visualizer'
|
||||
import { createServer } from '../utils/server'
|
||||
import { writeTypes } from '../utils/prepare'
|
||||
import { loadKit } from '../utils/kit'
|
||||
@ -22,18 +21,11 @@ export default defineNuxtCommand({
|
||||
|
||||
const { loadNuxt, buildNuxt } = await loadKit(rootDir)
|
||||
|
||||
const analyzeOptions: PluginVisualizerOptions = {
|
||||
template: 'treemap',
|
||||
projectRoot: rootDir,
|
||||
filename: join(statsDir, '{name}.html')
|
||||
}
|
||||
|
||||
const nuxt = await loadNuxt({
|
||||
rootDir,
|
||||
config: {
|
||||
build: {
|
||||
// @ts-ignore
|
||||
analyze: analyzeOptions
|
||||
analyze: true
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { join } from 'pathe'
|
||||
import { isCI, isTest } from 'std-env'
|
||||
import { normalizeURL, withTrailingSlash } from 'ufo'
|
||||
|
||||
@ -25,7 +26,19 @@ export default {
|
||||
* ```
|
||||
* @type {boolean | typeof import('webpack-bundle-analyzer').BundleAnalyzerPlugin.Options | typeof import('rollup-plugin-visualizer').PluginVisualizerOptions}
|
||||
*/
|
||||
analyze: false,
|
||||
analyze: {
|
||||
$resolve: (val, get) => {
|
||||
if(val !== true) {
|
||||
return val ?? false
|
||||
}
|
||||
const rootDir = get('rootDir')
|
||||
return {
|
||||
template: 'treemap',
|
||||
projectRoot: rootDir,
|
||||
filename: join(rootDir, '.nuxt/stats', '{name}.html')
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Enable the profiler in webpackbar.
|
||||
|
Loading…
Reference in New Issue
Block a user