Skip to content

Instantly share code, notes, and snippets.

@Swimburger
Last active November 2, 2021 11:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Swimburger/8edfc108797636cc9b5509d8588d170e to your computer and use it in GitHub Desktop.
Save Swimburger/8edfc108797636cc9b5509d8588d170e to your computer and use it in GitHub Desktop.
Create and Deploy Blazor WASM to Heroku using heroku-buildpack-static (ubuntu)
#!/bin/bash
# start onetime setup
# make sure to have 'jq' installed
# sudo snap install jq
mkdir BlazorWasmHeroku
cd BlazorWasmHeroku
dotnet new blazorwasm
heroku login
heroku plugins:install heroku-cli-static
AppId=$(heroku create --no-remote --json | jq -r '.id')
heroku buildpacks:set https://github.com/hone/heroku-buildpack-static -a $AppId
heroku static:init
# update static.json to including SPA routing
echo $(cat static.json | jq '.routes={"/**": "index.html"}') > static.json
# end onetime setup
dotnet publish -c Release -o release
heroku static:deploy -a $AppId
@Swimburger
Copy link
Author

For full-blown guides on deploying Blazor to other platforms, check out the Blazor category at swimburger.net: https://swimburger.net/blog/blazor?viewall=true#main-content

@Swimburger
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment