fresh icon indicating copy to clipboard operation
fresh copied to clipboard

Vite plugin for `vanilla-extract` does not work.

Open treejadey opened this issue 3 months ago • 2 comments

How to reproduce:

  1. Create a new Fresh project.
  2. Build the project with deno task build
  3. Add vanilla-extract and the vite plugin by running:
deno install --npm @vanilla-extract/css
deno install --npm --dev @vanilla-extract/vite-plugin
  1. Add the plugin to your Vite config like this:
import { defineConfig } from "vite";
import { fresh } from "@fresh/plugin-vite";
import { vanillaExtractPlugin } from "@vanilla-extract/vite-plugin";

export default defineConfig({
  plugins: [fresh(), vanillaExtractPlugin()],
});
  1. Run deno task build and get an error like the following:
Error Log
PS C:\Users\jade\Repositories\reproductiontest> deno task build
Task build vite build
error during build:
Error: Couldn't find parent package.json with a name field from 'C:/Users/jade/Repositories/reproductiontest'
    at Object.getPackageInfo (file:///C:/Users/jade/Repositories/reproductiontest/node_modules/.deno/@[email protected]/node_modules/@vanilla-extract/integration/dist/vanilla-extract-integration.cjs.prod.js:351:11)
    at BasicMinimalPluginContext.configResolved (file:///C:/Users/jade/Repositories/reproductiontest/node_modules/.deno/@[email protected]/node_modules/@vanilla-extract/vite-plugin/dist/vanilla-extract-vite-plugin.cjs.prod.js:110:33)
    at file:///C:/Users/jade/Repositories/reproductiontest/node_modules/.deno/[email protected]_2/node_modules/vite/dist/node/chunks/dep-C6pp_iVS.js:36390:87
    at Array.map (<anonymous>)
    at resolveConfig (file:///C:/Users/jade/Repositories/reproductiontest/node_modules/.deno/[email protected]_2/node_modules/vite/dist/node/chunks/dep-C6pp_iVS.js:36390:68)
    at eventLoopTick (ext:core/01_core.js:179:7)
    at async createBuilder (file:///C:/Users/jade/Repositories/reproductiontest/node_modules/.deno/[email protected]_2/node_modules/vite/dist/node/chunks/dep-C6pp_iVS.js:34583:19)
    at async CAC.<anonymous> (file:///C:/Users/jade/Repositories/reproductiontest/node_modules/.deno/[email protected]_2/node_modules/vite/dist/node/cli.js:647:19)

treejadey avatar Sep 11 '25 12:09 treejadey

Simple reproduction repo for this issue -> https://github.com/fry69/fresh-vite-vanilla-repro

Just run deno task build to provoke mentioned error.

fry69 avatar Sep 11 '25 13:09 fry69

Seems like an upstream issue. I think they're no accounting for Deno projects where package.json is not a requirement.

marvinhagemeister avatar Sep 12 '25 13:09 marvinhagemeister