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
Automatically load your server build (i.e. your server files built at dist/server/, or ${build.outDir}/server if you use vite.config.js > build.outDir).
It does so in an universal and portable way. (I.e. it works with every known environment such as Edge Deployments and Yarn PnP.)
importBuild.cjs
Usually, @brillout/vite-plugin-import-build does everything automagically and you don't have to do anything.
But, in some environments, you need to help @brillout/vite-plugin-import-build by adding the following to your server code:
// server.js
// Load server files built at dist/server/
// https://github.com/brillout/vite-plugin-import-build#importbuildcjs
import './path/to/dist/server/importBuild.cjs'
// Your server code (e.g. Express.js, Vercel Serverless/Edge, Cloudflare Worker, ...)
// ...If you use vite.config.js > build.outDir replace ./path/to/dist/server/importBuild.cjs with ./path/to/${build.outDir}/server/importBuild.cjs.
If you get following error, even though you're building your app after installing your app's dependencies and you aren't using Yarn PnP, then open a new issue – it's likely a bug that should be fixed.
Error: [@brillout/vite-plugin-import-build][Wrong Usage] Cannot find server build. (Re-)build your app (`$ vite build`) and try again. Note that you need the build your app (`$ vite build`) *after* installing your dependencies (`$ npm install`).
See https://github.com/brillout/vite-plugin-import-build/issues/4 to learn more about importBuild.cjs and why/when you need to import it manually.