DEV Community

Kinga
Kinga

Posted on • Updated on

rush dist:package for SPFx

Rush bulk commands are invoked separately for each project. Rush will look in each project's package.json file for a "scripts" entry whose name matches the command name. By default, the command will run for every project in the repo, according to the dependency graph (similar to how "rush build" works). The set of projects can be restricted e.g. using the "--to" or "--from" parameters.

See Custom commands for information on writing and using custom commands.

Package SPFx solution

# build prerelease
rush spfx:package-dev
# build stable
rush spfx:package
Enter fullscreen mode Exit fullscreen mode

These commands may be provided to dist:package using the --package-command parameter, to be executed for each changed project.
They run individually for each project in the repo. Rush looks for a corresponding script name in each project's package.json file.

## Prerelease -------------------
# package ALL as prerelease
rush dist:package --include-all --prerelease `
  --package-command 'spfx:package-dev'

# package ALL projects WITH version policy:
rush dist:package --include-all --prerelease --version-policy 'SPFx' `
  --package-command 'spfx:package-dev'

#  package CHANGED as prerelease
rush dist:package --prerelease `
  --package-command 'spfx:package-dev'

## Stable -------------------
# package ALL as stable
rush dist:package --include-all `
  --package-command 'spfx:package-dev'

# package ALL projects WITH version policy:
rush dist:package --include-all --version-policy 'SPFx' `
  --package-command 'spfx:package-dev'

#  package CHANGED as stable
rush dist:package `
  --package-command 'spfx:package-dev'
Enter fullscreen mode Exit fullscreen mode

spfx:package in package.json

Corresponding commands are added to package.json files for each selected project and may be adjusted as needed.

  "scripts": {
    "spfx:package": "gulp clean && gulp bundle --ship && gulp package-solution --ship",
    "spfx:package-dev": "gulp clean && gulp bundle --ship --prerelease && gulp package-solution --ship",
  }
Enter fullscreen mode Exit fullscreen mode

Copy packages to target location

rush spfx:copy  `
  --target-folder "C:\temp" `
  --copied-files "./sharepoint/solution/*.sppkg,./sharepoint/assets/elements.xml"  `
Enter fullscreen mode Exit fullscreen mode

This command may be provided to dist:package using the --copy-command parameter.
It runs individually for each project in the repo. Rush looks for a corresponding script name in each project's package.json file.

rush dist:package --include-all --prerelease `
  --package-command 'spfx:package-dev' `

To make sure that these changes will not be detected by `rush change`, the `package-solution.json` files are registered in [rush-project.json (experimental)](https://rushjs.io/pages/configs/rush-project_json) files specific to individual projects.
  --copy-command 'spfx:copy --target-folder "C:\temp" --copied-files "./sharepoint/solution/*.sppkg,./sharepoint/assets/elements.xml"'
Enter fullscreen mode Exit fullscreen mode

Top comments (0)