Storefront Next uses Vite as its build tool, providing fast development builds through native ES modules and optimized production builds through Rollup. The toolchain includes native TypeScript support and Vitest for testing.
Vite Configuration
The vite.config.ts file configures these plugins for your storefront.
reactRouter(): Enables React Router 7 framework mode with file-based routing and Server-Side Rendering (SSR).
tailwindcss(): Compiles Tailwind CSS styles.
tsconfigPaths(): Resolves TypeScript path aliases like @/components.
storefrontNextPlugin(): Prepares your build for deployment to Managed Runtime (MRT), including bundle formatting, manifest generation, and React Router compatibility patches.
You can add more Vite plugins to customize your build.
1// vite.config.ts2import{defineConfig}from "vite";3import{reactRouter}from "@react-router/dev/vite";4import tailwindcss from "@tailwindcss/vite";5import tsconfigPaths from "vite-tsconfig-paths";6import storefrontNextPlugin from "@salesforce/storefront-next-dev";78export default defineConfig({9 plugins:[reactRouter(), tailwindcss(), tsconfigPaths(), storefrontNextPlugin()],10});
Storefront Next Plugin Options
The storefrontNextPlugin accepts this optional configuration object.
Start development server with hot module replacement.
pnpm build
Create a production build.
pnpm start
Preview a production build locally.
pnpm push
Deploy to MRT.
pnpm typecheck
Run TypeScript type checking.
pnpm test
Run Vitest tests with coverage.
pnpm bundlesize:test
Build and validate bundle sizes.
pnpm bundlesize:analyze
Build and visualize bundle composition.
Source Maps
Production builds generate source maps by default. Source maps map minified code back to your original source files, giving you readable stack traces when errors occur.
Configure Source Maps in Vite
Control source map generation in vite.config.ts using Vite’s [build.sourcemap](https://vite.dev/config/build-options.html#build-sourcemap) option.
Generates .map files alongside your build output. (Default)
"hidden"
Generates .map files but omits the sourceMappingURL comment in bundles.
false
Disables source map generation entirely.
Enable Source Maps on Managed Runtime
Source maps are included in your deployed bundle, but MRT must be configured to use them at runtime. When enabled, MRT starts your server with the --enable-source-maps Node.js flag, which gives you original file names and line numbers in error stack traces.
Run pnpm bundlesize:test to validate that your build stays within limits. If a chunk exceeds the baseline 50-KB limit, add an explicit entry for that chunk with an approved limit.
To generate a visual treemap of your bundle composition, run pnpm bundlesize:analyze. This command helps you identify optimization opportunities.