windicss / windicss-webpack-plugin

🍃 Windi CSS for webpack ⚡
https://windicss.org/integrations/webpack.html
79 stars 19 forks source link

Next.js not working #106

Closed bfourgeaud closed 2 years ago

bfourgeaud commented 2 years ago

Describe the bug When installing windicss-webpack-plugin I get that error :

error - ./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[2].oneOf[8].use[1]!./node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[2].oneOf[8].use[2]!./node_modules/windicss-webpack-plugin/dist/loaders/virtual-module.js!./virtual:windi.css
Error: Cannot find module 'tailwindcss'
Require stack:
- E:\JEEBIE.ME\Projets\Clavier\dev\NEXT\eea-admin\node_modules\next\dist\build\webpack\config\blocks\css\plugins.js
- E:\JEEBIE.ME\Projets\Clavier\dev\NEXT\eea-admin\node_modules\next\dist\build\webpack\config\blocks\css\index.js
- E:\JEEBIE.ME\Projets\Clavier\dev\NEXT\eea-admin\node_modules\next\dist\build\webpack\config\index.js
- E:\JEEBIE.ME\Projets\Clavier\dev\NEXT\eea-admin\node_modules\next\dist\build\webpack-config.js
- E:\JEEBIE.ME\Projets\Clavier\dev\NEXT\eea-admin\node_modules\next\dist\server\dev\hot-reloader.js
- E:\JEEBIE.ME\Projets\Clavier\dev\NEXT\eea-admin\node_modules\next\dist\server\dev\next-dev-server.js
- E:\JEEBIE.ME\Projets\Clavier\dev\NEXT\eea-admin\node_modules\next\dist\server\next.js
- E:\JEEBIE.ME\Projets\Clavier\dev\NEXT\eea-admin\node_modules\next\dist\server\lib\start-server.js
- E:\JEEBIE.ME\Projets\Clavier\dev\NEXT\eea-admin\node_modules\next\dist\cli\next-dev.js
- E:\JEEBIE.ME\Projets\Clavier\dev\NEXT\eea-admin\node_modules\next\dist\bin\next
    at Array.map (<anonymous>)

next.config.ts

const WindiCSSWebpackPlugin = require('windicss-webpack-plugin')

module.exports = {
  reactStrictMode: true,
  images: {
    domains: ['media.graphcms.com'],
  },
  webpack(config) {
    config.plugins.push(new WindiCSSWebpackPlugin())
    return config
  },
}

_app.tsx

import { SessionProvider } from 'next-auth/react'
import Layout from "../components/Layout"
import 'windi.css'

function MyApp({
  Component,
  pageProps: { session, ...pageProps }
}) {
  return (
    <SessionProvider session={session}>
      <Layout>
        <Component {...pageProps} />
      </Layout>
    </SessionProvider>
  )
}

export default MyApp

windi.config.ts

import { defineConfig } from 'windicss/helpers'

export default defineConfig({
  extract: {
    include: ['**/*.{jsx,tsx,css}'],
    exclude: ['node_modules', '.git', '.next'],
  },
})

package.json

{
  "name": "eea-admin",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "bcrypt": "^5.0.1",
    "graphql": "^16.3.0",
    "graphql-request": "^4.0.0",
    "next": "12.0.10",
    "next-auth": "^4.0.0-beta.7",
    "react": "17.0.2",
    "react-dom": "17.0.2"
  },
  "devDependencies": {
    "@iconify/react": "^3.1.3",
    "@types/node": "^17.0.16",
    "@types/react": "^17.0.39",
    "eslint": "8.8.0",
    "eslint-config-next": "12.0.10",
    "windicss-webpack-plugin": "^1.6.4"
  }
}
bfourgeaud commented 2 years ago

OK found the problem, there was still the postcss.config.js file somewhere in the project ... Seems to made trouble !