ui icon indicating copy to clipboard operation
ui copied to clipboard

[bug]: Error: You forgot to add 'mini-css-extract-plugin' plugin (i.e. `{ plugins: [new MiniCssExtractPlugin()] }`),

Open jarrodwatts opened this issue 1 year ago • 3 comments

Describe the bug

When creating a new project with the CLI (without an existing Next.js project) using pnpm I get this error.

Affected component/components

How to reproduce

  • Empty directory
  • pnpm dlx shadcn@latest init
  • pnpm dlx shadcn@latest add button
  • Render a button on app/page.tsx
  • pnpm run dev

Codesandbox/StackBlitz link

No response

Logs

Error: You forgot to add 'mini-css-extract-plugin' plugin (i.e. `{ plugins: [new MiniCssExtractPlugin()] }`), please read https://github.com/webpack-contrib/mini-css-extract-plugin#getting-started

Import trace for requested module:
./app/globals.css

System Info

MacOS, Chrome

Before submitting

  • [X] I've made research efforts and searched the documentation
  • [X] I've searched for existing issues

jarrodwatts avatar Sep 02 '24 04:09 jarrodwatts

Did you find fix or workaround for that?

karrtopelka avatar Sep 14 '24 12:09 karrtopelka

@karrtopelka yeah. The instructions are in the error message on how to fix.

npm install --save-dev mini-css-extract-plugin

jarrodwatts avatar Sep 15 '24 01:09 jarrodwatts

In case this helps anyone, I added this to my next.config.mjs on CodeSandbox and the issue went away:

const nextConfig = {
  webpack: ( config, { buildId, dev, isServer, defaultLoaders, nextRuntime, webpack }) => {
    return config
  }
}

DaveyJake avatar Oct 01 '24 21:10 DaveyJake

In case this helps anyone, I added this to my next.config.mjs on CodeSandbox and the issue went away:

const nextConfig = {
  webpack: ( config, { buildId, dev, isServer, defaultLoaders, nextRuntime, webpack }) => {
    return config
  }
}

Thanks man, this also worked for me

manask-pradhan avatar Jan 08 '25 16:01 manask-pradhan