Skip to content

Commit db16233

Browse files
committed
feat: summary to list + homework assignment
1 parent c8cbc29 commit db16233

File tree

1 file changed

+10
-27
lines changed
  • src/content/tutorial/1-vite-plugin/1-yaml-plugin/5-summarize-yaml-plugin

1 file changed

+10
-27
lines changed

src/content/tutorial/1-vite-plugin/1-yaml-plugin/5-summarize-yaml-plugin/content.md

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,20 @@ focus: /vite.config.ts
88

99
Our custom Vite plugin can now intercept `*.yaml` file imports and convert them into Javascript.
1010

11-
<div class="mt-6 p-3 border-1 border-current border-dashed border-rd-md">
12-
<div class="mb-3">Source code loads YAML-file:</div>
13-
<code>import content from "./some-file.yaml"</code>
14-
</div>
11+
Before you head on to create your own plugins for loading some other non-Javascript files, let's summarize what we've done:
1512

16-
<div class="mt-6 w-full text-center">⬇️</div>
13+
<ol>
14+
<li>Source code loads YAML-file: <code class="whitespace-nowrap">import content from "./some-file.yaml"</code>
1715

18-
<div class="mt-6 p-3 border-1 border-current border-dashed border-rd-md">
19-
Vite plugin's <code>load()</code> hook intercepts <code>.yaml</code> request
20-
</div>
16+
<li class="mt2">Vite plugin's <code>load()</code> hook intercepts <code>.yaml</code> request</li>
2117

22-
<div class="mt-6 w-full text-center">⬇️</div>
18+
<li class="mt2">Contents of requested file are read from file system using <code>readFileSync()</code> from <code>node:fs</code> module</li>
2319

24-
<div class="mt-6 p-3 border-1 border-current border-dashed border-rd-md">
25-
Contents of requested file are read from file system using <code>readFileSync()</code> from <code>node:fs</code> module
26-
</div>
20+
<li class="mt2">YAML content is converted into Javascript using <code>parse()</code> from <code>yaml</code> module</li>
2721

28-
<div class="mt-6 w-full text-center">⬇️</div>
22+
<li class="mt2">Javascript object is serialized into text using <code>JSON.stringify()</code> and returned as default export from <code>load()</code> hook</li>
2923

30-
<div class="mt-6 p-3 border-1 border-current border-dashed border-rd-md">
31-
YAML content is converted into Javascript using <code>parse()</code> from <code>yaml</code> module
32-
</div>
24+
<li class="mt2">Source code successfully loads Javascript object from <code>.yaml</code> file import&nbsp;✅</li>
25+
</ol>
3326

34-
<div class="mt-6 w-full text-center">⬇️</div>
35-
36-
<div class="mt-6 p-3 border-1 border-current border-dashed border-rd-md">
37-
Javascript object is serialized into text using <code>JSON.stringify()</code> and returned as default export from <code>load()</code> hook
38-
</div>
39-
40-
<div class="mt-6 w-full text-center">⬇️</div>
41-
42-
<div class="mt-6 p-3 border-1 border-current border-dashed border-rd-md">
43-
Source code successfully loads Javascript object from <code>.yaml</code> file import ✅
44-
</div>
27+
📚 Homework: Build a Vite plugin that can import [`.csv` files](https://en.wikipedia.org/wiki/Comma-separated_values) directly into Javascript. You can even build your own minimal CSV-parser!

0 commit comments

Comments
 (0)