How do I upgrade from SAFE v4 to v5?
F# tools and dependencies
-
Get the latest dotnet tools such as Fable and Fantomas into your repository.
- Overwrite your
dotnet-tools.json
file from here. - Ensure tools have been downloaded to your machine with
dotnet tool restore
.
- Overwrite your
-
Use our preferred F# formatting style.
- Overwrite your
.editorconfig
file from here.
- Overwrite your
-
Migrate all dependencies to .NET 8.
-
Overwrite your
global.json
file from here. -
Update each of your project files to target .NET 8.
<PropertyGroup> <TargetFramework>net8.0</TargetFramework> </PropertyGroup>
-
Upgrade all .NET dependencies to the latest versions for SAFE v5:
- Run
dotnet paket remove Fable.React -p Client
. - Run
dotnet paket remove Feliz.Bulma -p Client
. - Overwrite your
paket.dependencies
file from here. - Overwrite your
paket.lock
file from here. - Overwrite your Shared project's
paket.references
file from here. - Run
dotnet paket install
to update the Shared project. - Manually re-add any custom dependencies that you previously had in any projects (Client, Server or Shared etc.):
cd
into the required project.dotnet paket add <package> --keep-minor
. This will download the latest version of the package you required but will not update any associated dependencies outside of their existing major version.
- Run
-
Javascript tools and dependencies
- Update all dependencies.
- Migrate from webpack to vite.
- Delete
webpack.config.js
- Add the
src/Client/vite.config.mts
file from here.
- Delete
Styling configuration
-
Install Tailwind.
-
Update HTML and F# code.
- Overwrite
src/Client/index.html
with this file. - Add the following lines at the top of
src/Client/App.fs
, after the existing open declarationsopen Fable.Core.JsInterop importSideEffects "./index.css"
- Overwrite
Automated tests
- Add the file
tests/Client/vite.config.mts
from here. - Overwrite the
tests/Client/index.html
file from here. - Add the file
.fantomasignore
from here.
Automated build
-
In the
Build.fs
file replace the following lines:Line 27:
- "client", dotnet [ "fable"; "-o"; "output"; "-s"; "--run"; "npm"; "run"; "build" ] clientPath ] + "client", dotnet [ "fable"; "-o"; "output"; "-s"; "--run"; "npx"; "vite"; "build" ] clientPath ]
Line 35:
- operating_system OS.Windows - runtime_stack Runtime.DotNet60 + operating_system OS.Linux + runtime_stack (DotNet "8.0")
Line 51:
- "client", dotnet [ "fable"; "watch"; "-o"; "output"; "-s"; "--run"; "npm"; "run"; "start" ] clientPath ] + "client", dotnet [ "fable"; "watch"; "-o"; "output"; "-s"; "--run"; "npx"; "vite" ] clientPath ]
Line 58:
- "client", dotnet [ "fable"; "watch"; "-o"; "output"; "-s"; "--run"; "npm"; "run"; "test:live" ] clientTestsPath ] + "client", dotnet [ "fable"; "watch"; "-o"; "output"; "-s"; "--run"; "npx"; "vite" ] clientTestsPath ]
Note: If you are using a template created prior to version v4.3, you may have the following string syntax for the
dotnet
commands and therefore the change you need to make will be slightly different.- "client", dotnet "fable -o output -s --run npm run build" clientPath + "client", dotnet "fable -o output -s --run npx vite build" clientPath
Additional resources
- VSCode Tailwind intellisense.
- Install the
Tailwind CSS Intellisense
extension. - Create the
.vscode/settings.json
file from here. The regexes in this file are for Feliz style DSL, if you want to support Fable.React DSL you will need to adapt the regexes.
- Install the