ssr-webpack

raw JSON →
7.0.14 verified Fri May 01 auth: no javascript

A framework-agnostic SSR webpack configuration for serverless deployment, supporting React (17/18/19) and Vue (2/3) with Vite, Webpack, or Rspack. Version 7.x (current 7.0.14) reduces dependency size by 2/3 and improves build speed 5-10x. Supports tight integration with Nest.js and Midway.js, and one-click deploy to Alibaba/Tencent Cloud Serverless. Actively maintained with weekly releases.

error Error: Cannot find module 'ssr-webpack'
cause Package not installed or wrong import path.
fix
Install package: npm install ssr-webpack@latest
error TypeError: srrWebpack is not a function
cause Using CJS require() instead of ESM import, or importing wrong export.
fix
Use import srrWebpack from 'ssr-webpack' (ESM) or require('ssr-webpack').default
error Error: The engine "node" is incompatible with this module.
cause Node version < 20.
fix
Upgrade Node to >= 20 and retry.
breaking v7 drops support for Node < 20. Upgrade Node to >= 20.
fix Install Node.js 20 or later.
breaking Default export changed from a webpack config object to an async function generating config.
fix Call srrWebpack() and await the result, not require('ssr-webpack') directly.
breaking Plugin system changed in v7. Old plugin imports from 'ssr-plugin-*' v6 may not work.
fix Update to @ssr/plugin-* packages and use new API.
deprecated The inlineConfig option is deprecated. Use chainWebpack instead.
fix Migrate overrides to chainWebpack callback.
gotcha When using with Vue, must also install ssr-plugin-vue and configure accordingly.
fix Add 'ssr-plugin-vue' to dependencies and import VueSSR plugin.
npm install ssr-webpack
yarn add ssr-webpack
pnpm add ssr-webpack

Generates a client-side SSR webpack config with React plugin and environment variable injection.

import srrWebpack from 'ssr-webpack';
import { ReactSSR } from 'ssr-plugin-react';

const config = await srrWebpack({
  type: 'client',
  chainWebpack: (chain) => {
    chain.plugin('define').tap(args => [{
      ...args[0],
      'process.env.API_BASE': JSON.stringify(process.env.API_BASE ?? 'http://localhost:3000/api')
    }]);
  },
  plugins: [
    new ReactSSR()
  ]
});

// Export for webpack (e.g., webpack-merge)
export default config;