{"id":20572,"library":"static-site-generator-webpack-plugin","title":"static-site-generator-webpack-plugin","description":"Minimal, unopinionated static site generator powered by webpack (v3.4.2, last updated Apr 2018). Compiles a custom render function with webpack and executes it for each path to produce static HTML files. Supports React/React Router universal rendering, automatic crawling of links, async rendering via callbacks or promises, and flexible multi-file output. Key differentiators: leaves rendering entirely to the user, works with any view library, and integrates tightly with webpack's build pipeline. Alternatives like Gatsby or Next.js are more opinionated and feature-rich.","status":"maintenance","version":"3.4.2","language":"javascript","source_language":"en","source_url":"https://github.com/markdalgleish/static-site-generator-webpack-plugin","tags":["javascript"],"install":[{"cmd":"npm install static-site-generator-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add static-site-generator-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add static-site-generator-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The plugin does not export an ES module; use CommonJS require. There is no default export for ES imports.","wrong":"import StaticSiteGeneratorPlugin from 'static-site-generator-webpack-plugin';","symbol":"StaticSiteGeneratorPlugin","correct":"const StaticSiteGeneratorPlugin = require('static-site-generator-webpack-plugin');"}],"quickstart":{"code":"// webpack.config.js\nconst StaticSiteGeneratorPlugin = require('static-site-generator-webpack-plugin');\nconst path = require('path');\n\nmodule.exports = {\n  entry: './render.js',\n  output: {\n    filename: 'render.js',\n    path: path.resolve(__dirname, 'dist'),\n    libraryTarget: 'umd'\n  },\n  plugins: [\n    new StaticSiteGeneratorPlugin({\n      paths: ['/hello/', '/world/'],\n      locals: { greet: 'Hello' }\n    })\n  ]\n};\n\n// render.js\nmodule.exports = (locals) => {\n  return `<html>${locals.greet} from ${locals.path}</html>`;\n};","lang":"javascript","description":"Configures webpack to generate static HTML files for /hello/ and /world/ using a simple render function."},"warnings":[{"fix":"Set output.libraryTarget: 'umd' in webpack config.","message":"The plugin requires webpack output.libraryTarget to be 'umd' or 'commonjs2', otherwise the render function cannot be required in Node context.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Ensure entry outputs a single bundle that contains the render function, or use the 'entry' option to specify which entry to use.","message":"The plugin expects a single JS entry module. With code splitting or multiple entries, you may need to use the 'entry' option or select a specific chunk for rendering.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"For webpack 5, consider alternatives like 'html-webpack-plugin' or custom plugin; this plugin may not work correctly.","message":"Webpack 4 compatibility was added in v3.4.0 via hooks API, but the plugin still relies on deprecated or changed APIs in webpack 5.","severity":"deprecated","affected_versions":">=3.4.0 <=3.4.2"},{"fix":"Use the 'paths' option for explicit control, or ensure crawler only targets relative URLs within your site.","message":"The 'crawl' option may follow external links, leading to infinite crawling or unintended pages being fetched. It only follows relative links and iframes.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure your entry file exports a function (module.exports = ...) and output.libraryTarget is set to 'umd' or 'commonjs2'.","cause":"The entry module does not export a function, or bundle is not correctly compiled.","error":"Error: No render function exported from bundle."},{"fix":"Use an older version of webpack (3.x) or check plugin compatibility with webpack 4+.","cause":"The plugin expects webpack stats object with 'assetsByChunkName' property, which may be missing in newer webpack versions.","error":"TypeError: Cannot read property 'assetsByChunkName' of undefined","affected_versions":">=4.0.0"},{"fix":"Ensure all required dependencies are either bundled (via webpack externals) or available in the Node environment where webpack runs.","cause":"This plugin assumes the compiled bundle is executed in a Node environment, but it may be missing dependencies that are not bundled (e.g., 'react-dom/server').","error":"Error: Cannot find module 'xxx'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}