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.
Common errors
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.
Warnings
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.
Install
npm install ssr-webpack yarn add ssr-webpack pnpm add ssr-webpack Imports
- ssr-webpack wrong
require('ssr-webpack')correctimport srrWebpack from 'ssr-webpack' - type ClientConfig
import type { ClientConfig } from 'ssr-webpack' - type ServerConfig
import type { ServerConfig } from 'ssr-webpack'
Quickstart
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;