JSPM

  • Created
  • Published
  • Downloads 12034
  • Score
    100M100P100Q149895F
  • License MIT

Package Exports

  • @brillout/vite-plugin-import-build
  • @brillout/vite-plugin-import-build/index.js
  • @brillout/vite-plugin-import-build/loadServerBuild
  • @brillout/vite-plugin-import-build/loadServerBuild.js
  • @brillout/vite-plugin-import-build/plugin
  • @brillout/vite-plugin-import-build/plugin.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@brillout/vite-plugin-import-build) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@brillout/vite-plugin-import-build

Little utility that automatically loads the server build (files at dist/server/).


Manual import

Most of the time @brillout/vite-plugin-import-build can automatically import the server build (files at dist/server/).

But, in some situations, it doesn't work and you have to import the server build manually.

If you keep getting the following error then import the server build manually.

[@brillout/vite-plugin-import-build][Wrong Usage] Cannot find server build. (Re-)build your app
and try again. If you still get this error, then you may need to manually import the server build.

If you aren't using Yarn PnP and you keep getting the error, then open a new issue. (If you aren't using Yarn PnP then the automatic import should always work.)

To manually import the server build:

// server.js

// Load server build, see https://github.com/brillout/vite-plugin-import-build#manual-import
import './path/to/dist/server/importBuild.cjs'

// Your server code (e.g. Express.js, Vercel Serverless/Edge Function, Cloudflare Worker, ...)
// ...

Make sure to import importBuild.cjs only in production: in development @brillout/vite-plugin-import-build isn't needed. See Conditional manual import if your production and development share the same server entry file.

If you use vite.config.js > build.outDir then replace dist/server/importBuild.cjs with ${build.outDir}/server/importBuild.cjs.

See How it works if you're curious and/or you want to learn more.