Movatterモバイル変換


[0]ホーム

URL:


Framework
Workflows
Production Build

Create a Production Build

To create a production bundle for distribution, run:

pnpmbuild# ORnpmrunbuild

Generating a zip bundle

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

pnpmpackage# ORnpmrunpackage

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

pnpmbuild--zip# ORnpmrunbuild----zip

With a specific target

Thebuild command accepts a--target flag in the form of<browser-name>-<manifest-version>. Use it to specify a browser and manifest version combination to build for:

plasmobuild--target=firefox-mv2

The final bundle will be available in thebuild/firefox-mv2-prod directory. You may use any pairs of target browser and manifest version.

For a list of officially supported targets,visit this link. These targets are recognized by the bundler, which will automatically handle some vendor-specific behavior for you.

The--target flag also enables you to:

  • Use a target-specific environment file:.env.<browser-name>
  • Use a target-specific entry files: e.gpopup.<browser-name>.tsx
  • Set the process.env.PLASMO_BROWSER to<browser-name>

The third feature works with deadcode elimination. Thus the following code:

if (process.env.PLASMO_BROWSER==="safari") {console.log("A")}else {console.log("B")}

Will be trimmed down toconsole.log("A") if the target issafari-mv3.

With a custom tag

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

plasmobuild--tag=staging

The command above will:

  • Create the bundle in thebuild/chrome-mv3-staging directory
  • Set theprocess.env.PLASMO_TAG environment variables tostaging
  • 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:

plasmobuild--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 aBundle Buddy (opens in a new tab) report:

plasmobuild--source-maps--bundle-buddy

Optimization

To create a bundle with minification disabled:

plasmo build --no-minify

To create an import-optimized build where the bundle deduplicate and hoist your dependency to the top of the bundle:

plasmo build --hoist

Note that hoisting can potentially break your dependency, especially those that import dynamic dependency via a plugin system. However, hoisting can significantly improve the bundling speed and reduce the size of your bundle.

You may combine these flags as needed.

Development ServerSubmission

[8]ページ先頭

©2009-2025 Movatter.jp