Repository: nuxt/nuxt
File: packages/schema/src/config/webpack.ts (TypeScript)

Code before:
import { defu } from 'defu'
import { basename, resolve } from 'pathe'
import { defineResolvers } from '../utils/definition'

export default defineResolvers({
  webpack: {
    resolve: {
      alias: {
        $resolve: async (val, get) => {
          const [srcDir, assetsDir, publicDir] = await Promise.all([
            get('srcDir'),
            get('dir.assets'),
            get('dir.public'),
          ])
          return {
            [basename(assetsDir)]: resolve(srcDir, assetsDir),
            [basename(publicDir)]: resolve(srcDir, publicDir),
            ...typeof val === 'object' ? val : {},
          }
        },
      },
    },
    /**
     * Nuxt uses `webpack-bundle-analyzer` to visualize your bundles and how to optimize them.
     *
     * Set to `true` to enable bundle analysis, or pass an object with options: [for webpack](https://github.com/webpack-contrib/webpack-bundle-analyzer#options-for-plugin) or [for vite](https://github.com/btd/rollup-plugin-visualizer#options).
     * @example
     * ```js
     * analyze: {
     *   analyzerMode: 'static'
     * }
     * ```
     * @type {boolean | { enabled?: boolean } & typeof import('webpack-bundle-analyzer').BundleAnalyzerPlugin.Options}
     */
    analyze: {
      $resolve: async (val, get) => {
        const value = typeof val === 'boolean' ? { enabled: val } : (val && typeof val === 'object' ? val : {})
        return defu(value, await get('build.analyze') as { enabled?: boolean } | Record<string, unknown>)
      },
    },

    /**
     * Enable the profiler in webpackbar.
     *

Review comment (suggestion):
```suggestion
          const [srcDir, assetsDir] = await Promise.all([
            get('srcDir'),
            get('dir.assets'),
          ])
          return {
            [basename(assetsDir)]: resolve(srcDir, assetsDir),
            ...typeof val === 'object' ? val : {},
          }
```

Code after:
import { defu } from 'defu'
import { defineResolvers } from '../utils/definition'

export default defineResolvers({
  webpack: {
    /**
     * Nuxt uses `webpack-bundle-analyzer` to visualize your bundles and how to optimize them.
     *
     * Set to `true` to enable bundle analysis, or pass an object with options: [for webpack](https://github.com/webpack-contrib/webpack-bundle-analyzer#options-for-plugin) or [for vite](https://github.com/btd/rollup-plugin-visualizer#options).
     * @example
     * ```js
     * analyze: {
     *   analyzerMode: 'static'
     * }
     * ```
     */
    analyze: {
      $resolve: async (val, get) => {
        const value = typeof val === 'boolean' ? { enabled: val } : (val && typeof val === 'object' ? val : {})
        return defu(value, await get('build.analyze') as { enabled?: boolean } | Record<string, unknown>)
      },
    },

    /**
     * Enable the profiler in webpackbar.
     *
     * It is normally enabled by CLI argument `--profile`.
     * @see [webpackbar](https://github.com/unjs/webpackbar#profile).
     */
    profile: process.argv.includes('--profile'),

    /**
     * Enables Common CSS Extraction.
     *
     * Using [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) under the hood, your CSS will be extracted
     * into separate files, usually one per component. This allows caching your CSS and
     * JavaScript separately.
     * @example
     * ```js
     * export default {
     *   webpack: {
     *     extractCSS: true,
     *     // or
     *     extractCSS: {