mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 17:52:29 +08:00

AssetDir is now inferred from the assets, if the assets is an embed.FS, by taking the relativ path to the index.html joined with the project root. The assetDir flag still exists and can be used if the inferring doesn't work, because the provided embed.FS wasn't defined in the main package.
26 lines
438 B
Go
26 lines
438 B
Go
package assetserver
|
|
|
|
import (
|
|
iofs "io/fs"
|
|
"path"
|
|
|
|
"github.com/wailsapp/wails/v2/internal/fs"
|
|
)
|
|
|
|
func prepareAssetsForServing(assets iofs.FS) (iofs.FS, error) {
|
|
if _, err := assets.Open("."); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
subDir, err := fs.FindPathToFile(assets, "index.html")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
assets, err = iofs.Sub(assets, path.Clean(subDir))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return assets, nil
|
|
}
|