Upload source maps for Webpack
Contents
AI wizard
Set up source map uploading automatically with our wizard by running this command in your project directory with your terminal (it also works for LLM coding agents like Cursor and Bolt):
Manual setup
- 1
Install the PostHog Webpack plugin
RequiredTerminal - 2
Add PostHog plugin to your Webpack config
RequiredAdd the following to your
webpack.config.jsfile:webpack.config.jsWhere you should set the following environment variables:
Environment Variable Description POSTHOG_API_KEYPersonal API key with at least writeaccess onerror trackingPOSTHOG_PROJECT_IDProject ID you can find in your project settings POSTHOG_HOST(optional) Your PostHog instance URL. Defaults to https://us.i.posthog.comIf you are using a CI/CD service, make sure these environment variables are added to your project settings, not just your local setup. This enables source maps to be automatically uploaded on your production build.