👾
NextJS v15 + vanilla-extract で公式に従ってもエラーになった
環境
- next:
15.2.4
- react:
^19.0.0
- typescript:
^5
- @vanilla-extract/css:
^1.17.1
公式通り vanilla-extract を導入したがエラーが発生した
下記 公式のドキュメントには書かれていないようだったのでメモとして、
vanilla-extract を Next.js に導入する
vanilla-extract を導入し npm run dev
で Next を起動すると下記のようなエラーが発生した
vanilla-extract の .css.ts
が意図した通り認識さていない...
結論: Next.js の Turbopack に Vanilla-extract が対応していない
Thanks for raising an issue. As documented in the turbopack documentation, using webpack-based Next.js plugins as-is from next.config.js is not yet supported. Until we can actually write plugins for turbopack (I don't think this is possible just yet), the VE next plugin will not work with next --turbo.
https://github.com/vanilla-extract-css/vanilla-extract/issues/1367#issuecomment-2016352850
現状 turbopack を使わない選択肢しかなさそう
package.json
"scripts": {
- "dev": "next dev --turbopack",
+ "dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
}
--turbopack
を取り npm run dev
し直せば問題なく vanilla-extract が使えるようになった
おわり
Discussion