Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Create bundle command #118

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,250 changes: 1,691 additions & 559 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ dioxus-html = { version = "0.3", features = ["hot-reload-context"] }
dioxus-core = { version = "0.3", features = ["serialize"] }
dioxus-autofmt = "0.3.0"
rsx-rosetta = { version = "0.3" }
tauri-bundler = "=1.3.*"
tauri-utils = "1.2.1"

[[bin]]
path = "src/main.rs"
Expand Down
3 changes: 2 additions & 1 deletion docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
- [Serve](./cmd/serve.md)
- [Clean](./cmd/clean.md)
- [Translate](./cmd/translate.md)
- [Bundle](./cmd/bundle.md)
- [Plugin Development](./plugin/README.md)
- [API.Log](./plugin/interface/log.md)
- [API.Command](./plugin/interface/command.md)
- [API.OS](./plugin/interface/os.md)
- [API.Directories](./plugin/interface/dirs.md)
- [API.Network](./plugin/interface/network.md)
- [API.Path](./plugin/interface/path.md)
- [API.Path](./plugin/interface/path.md)
67 changes: 67 additions & 0 deletions docs/src/cmd/bundle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Bundle

The `dioxus bundle` command can help you bundle a dioxus project.

```
dioxus-bundle
Bunle the Rust desktop app and all of its assets

USAGE:
dioxus bundle [OPTIONS]

OPTIONS:
--example <EXAMPLE> [default: ""]
--platform <PLATFORM> [default: "default_platform"]
--release [default: false]
--package <PACKAGE> [default: platform specific]
```

You can use this command to create an installer for a project in the `out_dir`:

```
dioxus bundle --release
```

## Target Platform

Use option `platform` choose build target platform:

```
# for desktop project
dioxus bundle --platform desktop
```

`platform` only supports `desktop` & `web`.

```
# for web project
dioxus bundle --platform web
```

## Bundle Example

You can use `--example {name}` to build a example code.

```
# bundle the `example/test`
dioxus bundle --exmaple test
```

## Target Package

Depending on the target platform, the following packages are available:
Windows:
`msi`: (.msi)
Macos:
`macos`: (.app)
`ios`: IOS app bundle
`dmg`: macOS DMG bundle (.dmg)
Linux:
`deb`: Debian package bundle (.deb)
`rpm`: RPM package bundle (.rpm)
`appimage`: AppImage bundle (.AppImage)

```
# bundle a msi package for windows
dioxus bundle --package msi
```
151 changes: 116 additions & 35 deletions docs/src/configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ We use `toml` to define some info for `dioxus` project.

### Application

1. ***name*** - project name & title
2. ***default_platform*** - which platform target for this project.
1. **_name_** - project name & title
2. **_default_platform_** - which platform target for this project.
```
# current support: web, desktop
# default: web
default_platform = "web"
```
change this to `desktop`, the `dioxus build & serve` will default build desktop app.
3. ***out_dir*** - which directory to put the output file; use `dioxus build & service`, the output will put at this directory, and the `assets` will be also copy to here.
```
out_dir = "dist"
```
4. ***asset_dir*** - which direcotry to put your `static, assets` file, cli will automatic copy all file to `out_dir`, so you can put some resource file in there, like `CSS, JS, Image` file.
3. **_out_dir_** - which directory to put the output file; use `dioxus build & service`, the output will put at this directory, and the `assets` will be also copy to here.
```
out_dir = "dist"
```
4. **_asset_dir_** - which direcotry to put your `static, assets` file, cli will automatic copy all file to `out_dir`, so you can put some resource file in there, like `CSS, JS, Image` file.
```
asset_dir = "public"
```
Expand All @@ -29,31 +29,34 @@ We use `toml` to define some info for `dioxus` project.

You can combine different tools with `dioxus`.

1. ***binaryen*** - Use the `binaryen` tooling suite.
1. **_binaryen_** - Use the `binaryen` tooling suite.
```
# current support: wasm-opt
# default: web
binaryen = { wasm_opt = true }
```
Use the `wasm_opt = true` key/pair value to activate optimization with wasm-opt.
When building on `release` profile, Dioxus will run `wasm_opt` with `-Oz` option.
2. ***tailwindcss*** - Use the `tailwindcss` standalone binary to generate a Tailwind CSS bundle file.
2. **_tailwindcss_** - Use the `tailwindcss` standalone binary to generate a Tailwind CSS bundle file.

```
tailwindcss = { input = "main.css", config = "tailwind.config.js" }
```

You can set two optional keys :
- input: path of the input CSS file (default value is "public/tailwind.css")
- config: path to the config file for Tailwind (default value is "src/tailwind.config.js")

When building on `release` profile, Dioxus will run `tailwindcss` with the `--minify` option.
- input: path of the input CSS file (default value is "public/tailwind.css")
- config: path to the config file for Tailwind (default value is "src/tailwind.config.js")

Note : Dioxus will automatically include the generated tailwind file in the `index.html`
When building on `release` profile, Dioxus will run `tailwindcss` with the `--minify` option.

Note : Dioxus will automatically include the generated tailwind file in the `index.html`

### Web.App

Web platform application config:

1. ***title*** - this value will display on the web page title. like `<title></title>` tag.
1. **_title_** - this value will display on the web page title. like `<title></title>` tag.
```
# HTML title tag content
title = "dioxus app | ⛺"
Expand All @@ -63,12 +66,12 @@ Web platform application config:

Web platform `dev-server` watcher config:

1. ***reload_html*** - a boolean value; when watcher trigger, regenerate `index.html` file.
1. **_reload_html_** - a boolean value; when watcher trigger, regenerate `index.html` file.
```
# when watcher trigger, regenerate the `index.html`
reload_html = true
```
2. ***watch_path*** - which files & directories will be watcher monitoring.
2. **_watch_path_** - which files & directories will be watcher monitoring.
```
watch_path = ["src", "public"]
```
Expand All @@ -77,7 +80,7 @@ Web platform `dev-server` watcher config:

Include some `CSS Javascript` resources into html file.

1. ***style*** - include some style(CSS) file into html.
1. **_style_** - include some style(CSS) file into html.
```
style = [
# include from public_dir.
Expand All @@ -86,21 +89,21 @@ Include some `CSS Javascript` resources into html file.
"https://cdn.jsdelivr.net/npm/bootstrap/dist/css/bootstrap.css"
]
```
2. ***script*** - include some script(JS) file into html.
```
style = [
# include from public_dir.
"./assets/index.js",
# or some asset from online cdn.
"https://cdn.jsdelivr.net/npm/bootstrap/dist/js/bootstrap.js"
]
2. **_script_** - include some script(JS) file into html.
```
style = [
# include from public_dir.
"./assets/index.js",
# or some asset from online cdn.
"https://cdn.jsdelivr.net/npm/bootstrap/dist/js/bootstrap.js"
]
```

### Web.Resource.Dev

Only include resources at `Dev` mode.

1. ***style*** - include some style(CSS) file into html.
1. **_style_** - include some style(CSS) file into html.
```
style = [
# include from public_dir.
Expand All @@ -109,26 +112,76 @@ Only include resources at `Dev` mode.
"https://cdn.jsdelivr.net/npm/bootstrap/dist/css/bootstrap.css"
]
```
2. ***script*** - include some script(JS) file into html.
```
style = [
# include from public_dir.
"./assets/index.js",
# or some asset from online cdn.
"https://cdn.jsdelivr.net/npm/bootstrap/dist/js/bootstrap.js"
]
2. **_script_** - include some script(JS) file into html.
```
style = [
# include from public_dir.
"./assets/index.js",
# or some asset from online cdn.
"https://cdn.jsdelivr.net/npm/bootstrap/dist/js/bootstrap.js"
]
```

### Web.Proxy

Proxy requests matching a path to a backend server.

1. ***backend*** - the URL to the backend server.
1. **_backend_** - the URL to the backend server.
```
backend = "http://localhost:8000/api/"
```
This will cause any requests made to the dev server with prefix /api/ to be redirected to the backend server at http://localhost:8000. The path and query parameters will be passed on as-is (path rewriting is not currently supported).

### Bundle

Information to include in the bundled output.

1. **_identifier_** - a string value; the identifier of the bundle.
```
identifier = "com.dioxus.app"
```
2. **_publisher_** - a string value; the publisher of the bundle.
```
publisher = "dioxus"
```
3. **_icon_** - a list of strings; the icons for the bundle.

```
icon = ["assets/icon.png"]
```

4. **_resources_** - a list of glob patterns; resources to include in the bundle.

```
resources = ["assets/*"]
```

5. **_copyright_** - a string value; the copyright of the bundle.

```
copyright = "Copyright (c) Jane Doe 2016. All rights reserved."
```

6. **_category_** - a string value; the category of the bundle. one of these values: `Business`, `Developer Tool`, `Education`, `Entertainment`, `Finance`, `Game`, `Action Game`, `Adventure Game`, `Arcade Game`, `Board Game`, `Card Game`, `Casino Game`, `Dice Game`, `Educational Game`, `Family Game`, `Kids Game`, `Music Game`, `Puzzle Game`, `Racing Game`, `Role-Playing Game`, `Simulation Game`, `Sports Game`, `Strategy Game`, `Trivia Game`, `Word Game`, `Graphics and Design`, `Healthcare and Fitness`, `Lifestyle`, `Medical`, `Music`, `News`, `Photography`, `Productivity`, `Reference`, `Social Networking`, `Sports`, `Travel`, `Utility`, `Video`, `Weather`,

```
category = "Business"
```

7. **_short_description_** - a string value; the short description of the bundle.

```
short_description = "A short description of the bundle."
```

8. **_long_description_** - a string value; the long description of the bundle.

```
long_description = """
A long description of the bundle.
"""
```

## Config example

```toml
Expand Down Expand Up @@ -181,4 +234,32 @@ script = []

[[web.proxy]]
backend = "http://localhost:8000/api/"

[bundle]

# Bundle identifier
identifier = "com.dioxus.app"

# Bundle publisher
publisher = "dioxus"

# Bundle icon. On windows, the icon file will default to `icons/icon.ico`
icon = ["assets/icon.png"]

# Bundle resources
resources = ["assets/*"]

# Bundle copyright
copyright = "Copyright (c) Jane Doe 2016. All rights reserved."

# Bundle category
category = "Business"

# Bundle short description
short_description = "A short description of the bundle."

# Bundle long description
long_description = """
A long description of the bundle.
"""
```
27 changes: 27 additions & 0 deletions src/assets/dioxus.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,30 @@ script = []
available = true

required = []

[bundler]
# Bundle identifier
identifier = "io.github.{{project-name}}"

# Bundle publisher
publisher = "{{project-name}}"

# Bundle icon
icon = ["icons/icon.png"]

# Bundle resources
resources = ["public/*"]

# Bundle copyright
copyright = ""

# Bundle category
category = "Utility"

# Bundle short description
short_description = "An amazing dioxus application."

# Bundle long description
long_description = """
An amazing dioxus application.
"""
Binary file added src/assets/icon.ico
Binary file not shown.
Loading