@vivid-front/bundler
v1.5.2
Published
A Node.js library for creating fake APIs from file structure.
Maintainers
Readme
@vivid-front/bundler
Helpers to inject HTTP client endpoint configuration into builds (Vite/Webpack) so your app can call the Fake API with correct base URLs per environment.
What it is
- Reads your vivid-front.config.* file and emits a define map for bundlers.
- Produces a global constant FAKE_API_HTTP that @vivid-front/http clients can read at runtime.
Install
- npm: npm install @vivid-front/bundler
- yarn: yarn add @vivid-front/bundler
- pnpm: pnpm add @vivid-front/bundler
Vite usage
- vite.config.ts:
import { defineConfig } from 'vite';
import { setupHttpClientEndpoints } from '@vivid-front/bundler';
export default defineConfig(({ mode }) => ({
define: {
...setupHttpClientEndpoints(mode),
},
}));Webpack usage
const { setupHttpClientEndpoints } = require('@vivid-front/bundler');
module.exports = (env) => ({
plugins: [
new webpack.DefinePlugin(setupHttpClientEndpoints(env.NODE_ENV || 'production')),
],
});Configuration
- Requires a vivid-front.config.(js|cjs|mjs|ts|cts) in your project root with an http.endpoints map.
- In development, baseUrl defaults to http://localhost:.
Node support
- Node >= 22.18.0
License MIT
