Production Build

Create a Production Build

To create a production bundle for distribution, run:

pnpm build
# OR
npm run build

Generating a zip bundle

To create a production zip bundle ready to be uploaded to the web stores, use the package command:

pnpm package
# OR
npm run package

If you would like to combine the building and packaging process, use the --zip flag with the build command instead:

pnpm build --zip
# OR
npm run build -- --zip

With a specific target

The build command accepts a --target flag. Use it to specify a browser and manifest version combination to build for:

plasmo build --target=firefox-mv2

The final bundle will be available in the build/firefox-mv2-prod directory.

For a list of officially supported targets, visit this link.

With a custom tag

Plasmo uses the prod tag for your production build. You can use the --tag flag to change this behavior:

plasmo build --tag=staging

The command above will:

  • Create the bundle in the build/chrome-mv3-staging directory
  • Set the process.env.PLASMO_TAG environment variables to staging
  • Parse and prioritize .env.staging or .env.staging.local if any exist

With source maps

By default, Plasmo does not generate source maps for your production bundle. However, you can use the --source-maps flag to change this behavior:

plasmo build --source-maps

Bundle Buddy

If you'd like to analyze your bundle, you can use the --bundle-buddy flag, combined with --source-maps to generate a Bundle Buddy (opens in a new tab) report:

plasmo build --source-maps --bundle-buddy