Skip to content

Can not build successfully with tailwindcss vite plugin #26

@nightire

Description

@nightire

I've encountered an error when running bun build, the error related with this issue: parcel-bundler/lightningcss#701

I changed vite.config.ts by following a workaround that other suggested:

import { reactRouter } from "@react-router/dev/vite"
import tailwindcss from "@tailwindcss/vite"
import mdx from "fumadocs-mdx/vite"
import { defineConfig } from "vite"
import tsconfigPaths from "vite-tsconfig-paths"
import * as MdxConfig from "./source.config"

export default defineConfig({
  plugins: [mdx(MdxConfig), tailwindcss(), reactRouter(), tsconfigPaths()],
  // Exclude lightningcss from bundling due to native bindings
  // @see https://github.com/parcel-bundler/lightningcss/issues/701
  ssr: { external: ["lightningcss"] }
})

with this setup, I can successfully build the app by running bun react-router build, however bun build still throws the same error, I have no idea how to solve this.

Below is the error messages:

$bun build --compile --minify --target bun --outfile server ./src/index.ts
17 |   module.exports = require(`../pkg`);
                                ^
error: Could not resolve: "../pkg"
    at /Users/nightire/Code/github.com/choice-form/core-ai/apps/server/node_modules/lightningcss/node/index.js:17:28

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions