@@ -44,9 +44,9 @@ $ npm install -D MithrilJS/mithril.d.ts#next
44
44
45
45
### Create a project locally
46
46
47
- You can use one of several existing Mithril starter templates such as
48
- * [ mithril-esbuild-starter] ( https://github.com/kevinfiol/mithril-esbuild-starter )
47
+ You can use one of several existing Mithril.js starter templates such as
49
48
* [ mithril-vite-starter] ( https://github.com/ArthurClemens/mithril-vite-starter )
49
+ * [ mithril-esbuild-starter] ( https://github.com/kevinfiol/mithril-esbuild-starter )
50
50
* [ mithril-rollup-starter] ( https://github.com/kevinfiol/mithril-rollup-starter )
51
51
52
52
For example, if you'd like to get started with ` mithril-esbuild-starter ` , run the following commands:
@@ -66,55 +66,56 @@ npm run dev
66
66
67
67
### Quick start with [ esbuild] ( https://esbuild.github.io/ )
68
68
69
- 1 . Initialize the directory as an npm package
69
+ 1 . Initialize the directory as an npm package.
70
70
``` bash
71
71
$ npm init --yes
72
72
```
73
73
74
- 2 . install required tools
74
+ 2 . Install required tools.
75
75
``` bash
76
76
$ npm install mithril
77
77
$ npm install esbuild --save-dev
78
78
```
79
79
80
80
3 . Add a "start" entry to the scripts section in ` package.json ` .
81
- ``` json
82
- {
83
- "..." : " ..." ,
84
- "scripts" : {
85
- "start" : " esbuild ./src/index.js --bundle --outfile=./bin/main.js --watch"
81
+ ```json
82
+ {
83
+ "...": "...",
84
+ "scripts": {
85
+ "start": "esbuild index.js --bundle --outfile=bin/main.js --watch"
86
+ }
86
87
}
87
- }
88
- ```
88
+ ```
89
89
90
- Optionally, if you'd like to use JSX, you can use the ` --jsx-factory ` and ` --jsx-fragment ` flags with esbuild.
90
+ Optionally, if you'd like to use JSX, you can use the `--jsx-factory` and `--jsx-fragment` flags with esbuild.
91
91
92
- ``` json
93
- {
94
- "..." : " ..." ,
95
- "scripts" : {
96
- "start" : " esbuild src/index.js --bundle --outfile=public/app.js --jsx-factory=m --jsx-fragment='\" [\" ' --watch"
92
+ ```json
93
+ {
94
+ "...": "...",
95
+ "scripts": {
96
+ "start": "esbuild index.js --bundle --outfile=bin/main.js --jsx-factory=m --jsx-fragment='\"[\"' --watch"
97
+ }
97
98
}
98
- }
99
- ```
99
+ ```
100
100
101
- 4 . Create ` src/ index.js` file.
101
+ 4 . Create ` index.js ` file.
102
102
``` javascript
103
103
import m from " mithril" ;
104
- m .render (document .body , " hello world" );
104
+ m .render (document .getElementById ( " app " ) , " hello world" );
105
105
```
106
106
107
- 5 . create ` index.html `
107
+ 5 . Create ` index.html ` file.
108
108
``` html
109
109
<!DOCTYPE html>
110
110
<body >
111
+ <div id =" app" ></div >
111
112
<script src =" bin/main.js" ></script >
112
113
</body >
113
114
```
114
115
115
- 6 . run bundler
116
+ 6 . Run your bundler script.
116
117
``` bash
117
118
$ npm run start
118
119
```
119
120
120
- 7 . open ` index.html ` in a browser
121
+ 7 . Open ` index.html ` in a browser. You should see ` hello world ` rendered on your page.
0 commit comments