question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

support for extending build within `nuxt.config`

See original GitHub issue

Environment


  • Operating System: Darwin
  • Node Version: v14.17.0
  • Nuxt Version: 3.0.0-27277498.850ef69
  • Package Manager: yarn@1.22.17
  • Bundler: Vite
  • User Config: target, css, publicRuntimeConfig, buildModules, modules, intlify, robots, build
  • Runtime Modules: @nuxtjs/robots@2.5.0
  • Build Modules: nuxt-windicss@2.0.12, @intlify/nuxt3@0.1.8

Reproduction

https://codesandbox.io/s/gallant-danny-xuwkr?file=/nuxt.config.ts

Describe the bug

I am trying to add a loader to my nuxt application. in Nuxt 2 I usually use the build.extend function to extend rules and add my rule, but in Nuxt 3 I am not able to do that. If you look at reproduction, there is a type error for extend key on error.

How to do that? In documentation is missing.

Thank you for help!

Additional context

No response

Logs

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
danielroecommented, Nov 24, 2021

For now, for vite, you can use vite:extend or vite:extendConfig. For webpack, you can use webpack:config.

import { defineNuxtConfig } from 'nuxt3'

export default defineNuxtConfig({
  hooks: {
    'vite:extend' ({ nuxt, config }) {},
    'vite:extendConfig' (clientConfig, { isClient, isServer }) {},
    'webpack:config' (configs) {}
  }
})
2reactions
danielroecommented, Apr 15, 2022

I think we’ve decided that the best approach is to use direct configuration of vite or webpack keys, hooks, or a custom module with extendWebpackConfig, extendViteConfig, addWebpackPlugin or addVitePlugin (utilities exported from @nuxt/kit).

cc: @pi0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration - Nuxt
You can extend nuxt's webpack configuration via the extend option in your nuxt.config.js . The extend option of the build property is a...
Read more >
The build Property - Nuxt
Extend the webpack configuration manually for the client & server bundles. ... The extend is called twice, one time for the server bundle,...
Read more >
Nuxt configuration file
This option lets you define the CSS files, modules, and libraries you want to include globally (on every page). ... You can omit...
Read more >
The extendPlugins Property - Nuxt
The extendPlugins property lets you customize Nuxt plugins. (options.plugins ). ... You may want to extend plugins or change plugins order created by...
Read more >
Commands and Deployment - Nuxt
nuxt dev - Launch the development server. · nuxt build - Build and optimize your application with webpack for production. · nuxt start...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found