From e7bb3b3e83c040bef9cdcbd2dd1c2e89e3b79ee5 Mon Sep 17 00:00:00 2001
From: stffabi
Date: Tue, 7 Dec 2021 03:26:55 +0100
Subject: [PATCH 1/4] [v2] Omit empty assetdir and reloaddirs in wails.json
---
v2/internal/project/project.go | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/v2/internal/project/project.go b/v2/internal/project/project.go
index 96d43358c..02253f28d 100644
--- a/v2/internal/project/project.go
+++ b/v2/internal/project/project.go
@@ -13,9 +13,9 @@ type Project struct {
/*** Application Data ***/
Name string `json:"name"`
- AssetDirectory string `json:"assetdir"`
+ AssetDirectory string `json:"assetdir,omitempty"`
- ReloadDirectories string `json:"reloaddirs"`
+ ReloadDirectories string `json:"reloaddirs,omitempty"`
BuildCommand string `json:"frontend:build"`
InstallCommand string `json:"frontend:install"`
From d8fe011509a0c36faf156efd31ec33e19860c46d Mon Sep 17 00:00:00 2001
From: stffabi
Date: Tue, 7 Dec 2021 03:30:33 +0100
Subject: [PATCH 2/4] [v2] Update docs with new assetdir management and add
reloaddirs
---
website/docs/guides/application-development.mdx | 2 +-
website/docs/guides/ides.mdx | 3 +--
website/docs/guides/migrating.mdx | 3 ++-
website/docs/howdoesitwork.mdx | 4 +---
website/docs/reference/cli.mdx | 3 ++-
website/docs/reference/project-config.mdx | 3 ++-
6 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/website/docs/guides/application-development.mdx b/website/docs/guides/application-development.mdx
index 46f088597..f96496145 100644
--- a/website/docs/guides/application-development.mdx
+++ b/website/docs/guides/application-development.mdx
@@ -165,7 +165,7 @@ If these 2 keys aren't given, then Wails does absolutely nothing with the fronte
Running `wails dev` will start the built in dev server which will start a file watcher in your project directory. By
default, if any file changes, wails checks if it was an application file (default: `.go`, configurable with `-e` flag).
-If it was, then it will rebuild your application and relaunch it. If the changed file was in the `assetdir` directory,
+If it was, then it will rebuild your application and relaunch it. If the changed file was in the assets,
it will issue a reload after a short amount of time.
The dev server uses a technique called "debouncing" which means it doesn't reload straight away,
diff --git a/website/docs/guides/ides.mdx b/website/docs/guides/ides.mdx
index fda70ebf6..5e47152b3 100644
--- a/website/docs/guides/ides.mdx
+++ b/website/docs/guides/ides.mdx
@@ -46,8 +46,7 @@ The 2 files generated are `tasks.json` and `launch.json`. Below are the files ge
"program": "${workspaceFolder}/build/bin/myproject.exe",
"preLaunchTask": "build",
"cwd": "${workspaceFolder}",
- "env": {},
- "args": ["-assetdir", "frontend/src"]
+ "env": {}
},
]
}
diff --git a/website/docs/guides/migrating.mdx b/website/docs/guides/migrating.mdx
index bafc26ac5..921a65929 100644
--- a/website/docs/guides/migrating.mdx
+++ b/website/docs/guides/migrating.mdx
@@ -199,7 +199,8 @@ The format of the file is slightly different. Here is a comparison:
| frontend / serve | | Removed |
| tags | | Removed |
| | wailsjsdir | The directory to generate wailsjs modules |
-| | assetdir | The directory of the compiled frontend assets for `dev` mode |
+| | assetdir | The directory of the compiled frontend assets for `dev` mode. This is normally inferred and could be left empty. |
+| | reloaddirs | Comma separated list of additional directories to watch for changes and to trigger reloads in `dev` mode. This is only needed for some more advanced asset configurations. |
diff --git a/website/docs/howdoesitwork.mdx b/website/docs/howdoesitwork.mdx
index 6b8b368a6..aadaf3139 100644
--- a/website/docs/howdoesitwork.mdx
+++ b/website/docs/howdoesitwork.mdx
@@ -106,9 +106,7 @@ As production binaries use the files contained in `embed.FS`, there are no exter
the application.
When running in development mode using the `wails dev` command, the assets are loaded off disk, and any changes result
-in a "live reload". The location of the assets needs to be passed to the `wails dev` command using the `-assetdir` flag
-and is likely to be the same as the embed path. It is hoped that in the future we can calculate this from the `embed.FS`
-itself.
+in a "live reload". The location of the assets will be inferred from the `embed.FS`.
More details can be found in the [Application Development Guide](/docs/guides/application-development).
diff --git a/website/docs/reference/cli.mdx b/website/docs/reference/cli.mdx
index 916574198..4c0cc6c95 100644
--- a/website/docs/reference/cli.mdx
+++ b/website/docs/reference/cli.mdx
@@ -130,10 +130,11 @@ Your system is ready for Wails development!
| Flag | Description | Default |
| :------------------- | :-------------------------------------- | :------------------------- |
-| -assetdir "./path/to/assets" | The path to your compiled assets | Value in `wails.json` |
+| -assetdir "./path/to/assets" | Serve assets from the given directory instead of using the provided asset FS | Value in `wails.json` |
| -browser | Opens a browser to `http://localhost:34115` on startup | |
| -compiler "compiler"| Use a different go compiler to build, eg go1.15beta1 | go |
| -e | Extensions to trigger rebuilds (comma separated) | go |
+| -reloaddirs | Additional directories to trigger reloads (comma separated) | Value in `wails.json` |
| -ldflags "flags" | Additional ldflags to pass to the compiler | |
| -tags "extra tags" | Build tags to pass to compiler (quoted and space separated) | |
| -loglevel "loglevel"| Loglevel to use - Trace, Debug, Info, Warning, Error | Debug |
diff --git a/website/docs/reference/project-config.mdx b/website/docs/reference/project-config.mdx
index f27da3fe3..e74a571af 100644
--- a/website/docs/reference/project-config.mdx
+++ b/website/docs/reference/project-config.mdx
@@ -9,7 +9,8 @@ The project config resides in the `wails.json` file in the project directory. Th
```json
{
"name": "[The project name]",
- "assetdir": "[Relative path to the directory containing the compiled assets]",
+ "assetdir": "[Relative path to the directory containing the compiled assets, this is normally inferred and could be left empty]",
+ "reloaddirs": "[Additional directories to trigger reloads (comma separated), this is only used for some advanced asset configurations]",
"frontend:install": "[The command to install node dependencies, run in the frontend directory - often `npm install`]",
"frontend:build": "[The command to build the assets, run in the frontend directory - often `npm run build`]",
"frontend:dev": "[This command is run in a separate process on `wails dev`. Useful for 3rd party watchers]",
From f034163da5f5f975a49b2a8755b511263c9948a8 Mon Sep 17 00:00:00 2001
From: stffabi
Date: Tue, 7 Dec 2021 03:31:40 +0100
Subject: [PATCH 3/4] [v2] Update wails.json with updated assetdir from `wails
dev`
Makes the code consistent with the docs
---
v2/cmd/wails/internal/commands/dev/dev.go | 1 +
1 file changed, 1 insertion(+)
diff --git a/v2/cmd/wails/internal/commands/dev/dev.go b/v2/cmd/wails/internal/commands/dev/dev.go
index 169c61687..c8d23f5ec 100644
--- a/v2/cmd/wails/internal/commands/dev/dev.go
+++ b/v2/cmd/wails/internal/commands/dev/dev.go
@@ -309,6 +309,7 @@ func loadAndMergeProjectConfig(cwd string, flags *devFlags) (*project.Project, e
if flags.assetDir != projectConfig.AssetDirectory {
projectConfig.AssetDirectory = filepath.ToSlash(flags.assetDir)
+ shouldSaveConfig = true
}
if flags.assetDir != "" {
From a98d55db586ab6dfa990357df26b6a987a0d4dc2 Mon Sep 17 00:00:00 2001
From: stffabi
Date: Tue, 7 Dec 2021 03:32:54 +0100
Subject: [PATCH 4/4] [v2] Update wails.json with updated reloaddirs from
`wails dev`
---
v2/cmd/wails/internal/commands/dev/dev.go | 1 +
website/docs/reference/cli.mdx | 2 +-
website/docs/reference/project-config.mdx | 2 +-
3 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/v2/cmd/wails/internal/commands/dev/dev.go b/v2/cmd/wails/internal/commands/dev/dev.go
index c8d23f5ec..77b7b36a6 100644
--- a/v2/cmd/wails/internal/commands/dev/dev.go
+++ b/v2/cmd/wails/internal/commands/dev/dev.go
@@ -325,6 +325,7 @@ func loadAndMergeProjectConfig(cwd string, flags *devFlags) (*project.Project, e
if flags.reloadDirs != projectConfig.ReloadDirectories {
projectConfig.ReloadDirectories = filepath.ToSlash(flags.reloadDirs)
+ shouldSaveConfig = true
}
if flags.devServerURL == defaultDevServerURL && projectConfig.DevServerURL != defaultDevServerURL && projectConfig.DevServerURL != "" {
diff --git a/website/docs/reference/cli.mdx b/website/docs/reference/cli.mdx
index 4c0cc6c95..551e671c5 100644
--- a/website/docs/reference/cli.mdx
+++ b/website/docs/reference/cli.mdx
@@ -146,7 +146,7 @@ Your system is ready for Wails development!
| -appargs "args" | Arguments passed to the application in shell style | |
| -platform "platform" | Platform/Arch to target | `runtime.GOOS` |
-If the `assetdir`, `wailsjsdir`, `debounce` or `devserverurl` flags are provided on the command line, they are saved in
+If the `assetdir`, `reloaddirs`, `wailsjsdir`, `debounce` or `devserverurl` flags are provided on the command line, they are saved in
`wails.json`, and become the defaults for subsequent invocations.
Example:
diff --git a/website/docs/reference/project-config.mdx b/website/docs/reference/project-config.mdx
index e74a571af..c3b624274 100644
--- a/website/docs/reference/project-config.mdx
+++ b/website/docs/reference/project-config.mdx
@@ -26,5 +26,5 @@ The project config resides in the `wails.json` file in the project directory. Th
This file is read by the Wails CLI when running `wails build` or `wails dev`.
-The `assetdir`, `wailsjsdir`, `debounceMS` and `devserverurl` flags in `wails build/dev` will update the project config
+The `assetdir`, `reloaddirs`, `wailsjsdir`, `debounceMS` and `devserverurl` flags in `wails build/dev` will update the project config
and thus become defaults for subsequent runs.
\ No newline at end of file