You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-32Lines changed: 16 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
[](https://www.npmjs.com/package/vite-plugin-elm/v/next)
A plugin enables you to compile an Elm [application](https://package.elm-lang.org/packages/elm/browser/latest/Browser#application)/[document](https://package.elm-lang.org/packages/elm/browser/latest/Browser#document)/[element](https://package.elm-lang.org/packages/elm/browser/latest/Browser#element)on your [Vite](https://github.com/vitejs/vite) project. [Hot module replacement](https://vitejs.dev/guide/features.html#hot-module-replacement) works roughly in development.
7
+
A plugin that enables us to compile an Elm [application](https://package.elm-lang.org/packages/elm/browser/latest/Browser#application), [document](https://package.elm-lang.org/packages/elm/browser/latest/Browser#document), or [element](https://package.elm-lang.org/packages/elm/browser/latest/Browser#element)within your [Vite](https://github.com/vitejs/vite) project. In development, [hot module replacement](https://vitejs.dev/guide/features.html#hot-module-replacement) works to some extent.
8
8
9
9
```ts
10
10
import { Elm } from'./MyApplication.elm'
@@ -18,7 +18,7 @@ Elm.MyApplication.init()
18
18
npm i -D vite-plugin-elm
19
19
```
20
20
21
-
Update`vite.config.(js|ts)`
21
+
In`vite.config.(js|ts)`:
22
22
23
23
```ts
24
24
import { defineConfig } from'vite'
@@ -29,73 +29,57 @@ export default defineConfig({
29
29
})
30
30
```
31
31
32
-
Then you can import `.elm` file like:
32
+
Then you can import a `.elm` file and run it like:
33
33
34
34
```ts
35
35
import { Elm } from'./Hello.elm'
36
-
```
37
-
38
-
then
39
36
40
-
```ts
41
37
// Mount "Hello" Browser.{element,document} on #root
42
38
Elm.Hello.init({
43
39
node: document.getElementById('root'),
44
40
flags: "Initial Message"
45
41
})
46
42
```
47
43
48
-
See [`/example`](/example)dir to play with an actual Vite project. And[this working website](https://github.com/hmsk/hmsk.me)may help you to learn how to use.
44
+
You can explore the [`/example`](/example)directory to experiment with an actual Vite project. Additionally,[this functional website](https://github.com/hmsk/hmsk.me)can serve as a helpful resource to learn how to use it effectively.
When it's `false`, disables debug mode in both development and production. Conversely, enables debug mode even in production by `true`. **When production build gets debug mode, Elm's compile optimization doesn't happen**.
58
+
When set to `false`, it disables debug mode in both development and production. Conversely, setting it to `true`enables debug mode even in production. It's important to note that **when the production build has debug mode enabled, Elm's compiler optimizations do not take place**.
By giving a boolean, can control build optimization, useful to use `Debug`[elm functions](https://package.elm-lang.org/packages/elm/core/latest/Debug)
62
+
You can control build optimization by providing a boolean value, which can be useful for using [`Debug`](https://package.elm-lang.org/packages/elm/core/latest/Debug) functions in your Elm code.
When true, optimize build and forbid usage of `Debug` elm functions.
83
-
When specify optimize attribute, had to tell if need to debug or not. It's not why you want to make debug traces you want to see all actions.
68
+
When set to `true`, it optimizes the build and prohibits the usage of Debug Elm functions. If you specify the optimize attribute, you must indicate whether debugging is needed. This is because you might want to have debug traces for the purpose of observing all actions, not necessarily for debugging specific issues.
84
69
85
70
## Static Assets Handling
86
71
87
-
This plugin supports importing assets by giving a particular tag `[VITE_PLUGIN_ELM_ASSET:<path to asset>]` to leverage [Vite's asset handling](https://vitejs.dev/guide/assets.html#importing-asset-as-url).
88
-
When Elm code has a string, this plugin replaces it with an imported asset. That string should be just a string without any concatenation.
72
+
This plugin supports importing assets by using a specific tag `[VITE_PLUGIN_ELM_ASSET:<path to asset>]` to leverage [Vite's asset handling](https://vitejs.dev/guide/assets.html#importing-asset-as-ur). When your Elm code contains a tag, this plugin replaces that string with the imported asset. It's important to note that the string should be a standalone string without any concatenation.
## Combine multiple main files (Experimental from `2.7.0-beta.1`)
92
+
## Combine multiple main files (Experimental)
109
93
110
-
By passing importing path via `with` URL-ish parameter(s), the plugin compiles multiple main files in a single compilation process. That generates a single `Elm` export which has multiple properties for each given main files. This way reduces bundle size comparing to a total size of importing each file separately since common modules/Elm core codes are not repeated.
94
+
By passing importing paths via the `with` URL-ish parameter(s), the plugin compiles multiple main files in a single compilation process. This results in a single Elm export that contains multiple properties, each corresponding to a given main file. This feature helps reduce the bundle size when compared to importing each file separately because common modules and Elm core code are not repeated.
111
95
112
96
```ts
113
97
// `Elm.App` and `Elm.Another`, both can work as like importing individually.
0 commit comments