Skip to content

Commit cb8fe2c

Browse files
committed
docs: update README with expanded file naming conventions and technical implementation details
1 parent f978911 commit cb8fe2c

1 file changed

Lines changed: 30 additions & 13 deletions

File tree

README.md

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@ JSDA relies heavily on JavaScript template literals for HTML and CSS (e.g., `/*h
112112

113113
For the best developer experience, we strongly recommend enabling syntax highlighting for these template strings in your IDE.
114114

115-
If you are using **VS Code**, install the [es6-string-html](https://github.com/0x00000001A/es6-string-html) extension. This will automatically highlight HTML and CSS embedded inside your JavaScript files.
115+
If you are using **VS Code**, install the extension (F.e. [es6-string-html](https://github.com/0x00000001A/es6-string-html)). This will highlight HTML, SVG and CSS embedded inside your JavaScript files.
116116

117117
### Optional TypeScript Setup
118118

119-
JSDA-Stack Template uses JSDoc annotations within standard JavaScript files to provide type safety via TypeScript. If you do not have TypeScript installed globally or supported natively in your IDE, you can still run type checks locally.
119+
We use JSDoc annotations within standard JavaScript files to provide type safety via TypeScript. If you do not have TypeScript installed globally or supported natively in your IDE, you can still run type checks locally.
120120

121-
Simply install `typescript` as a dev dependency:
121+
Install `typescript` as a dev dependency:
122122

123123
```bash
124124
npm install -D typescript
@@ -132,7 +132,7 @@ npm run check:types
132132

133133
This will run `npx tsc --noEmit` to validate your types against `tsconfig.json` without unnecessary compiling the source code.
134134

135-
## Configuration
135+
## Project Configuration
136136

137137
All project behavior is controlled via `project.cfg.js`:
138138

@@ -149,16 +149,33 @@ All project behavior is controlled via `project.cfg.js`:
149149

150150
Cloud Images Toolkit is configured separately in `cit-config.json`. See the [CIT documentation](https://github.com/rnd-pro/cloud-images-toolkit) for details.
151151

152-
## File Conventions
152+
## File Naming and Syntax Conventions
153+
154+
JSDA heavily embraces a **convention-over-configuration** approach. By leveraging strict file naming patterns, JSDA generates various types of web assets directly from JavaScript modules without requiring complex build configuration files. The default export of these modules must simply be a string (or a function returning a string) containing the raw asset data.
155+
156+
| Pattern | Output | Purpose |
157+
|---|---|---|
158+
| `[name].html.js` | `[name].html` | Dynamic HTML generator (exports an HTML string). |
159+
| `[name].css.js` | `[name].css` | CSS module (exports a CSS string). |
160+
| `[name].svg.js` | `[name].svg` | SVG graphic (exports an SVG markup string). |
161+
| `[name].json.js` | `[name].json` | JSON data payload (exports a JSON string). |
162+
| `index.js` | `index.js` | JS bundle entry point. |
163+
| `*.tpl.html` | n/a | Static template file containing `{[PLACEHOLDER]}` tags. |
164+
165+
### The `index.*.js` Pattern and SSG
166+
167+
During Static Site Generation (SSG), JSDA-Kit uses the file structure to reflect output path by scanning specifically for files matching the `index.*.js` pattern (which includes double extensions like `index.html.js` as well as plain `index.js`).
168+
169+
These files determine the output file path:
170+
- `src/static-pages/about/index.html.js``dist/about/index.html`
171+
- `src/static-pages/app/index.js``dist/app/index.js` (bundled and minified automatically)
172+
173+
They act as the default entry points for their containing directories.
174+
175+
### MIME Type Resolution and Minification
176+
177+
The double-extension pattern (`.[ext].js`) tells JSDA-Kit exactly what the final output format is. This `[ext]` is used for **proper MIME type resolution** during dynamic serving and dictates which minification pipeline to apply during SSG builds (e.g., HTML minifier for `.html.js`, CSS minifier for `.css.js`).
153178

154-
| Pattern | Purpose |
155-
|---|---|
156-
| `*.html.js` | Page generator — default export is an HTML string |
157-
| `*.css.js` | CSS module — default export is a CSS string |
158-
| `*.tpl.html` | Static HTML template with `{[PLACEHOLDER]}` syntax |
159-
| `logic.js` | Component logic (Symbiote.js class + registration) |
160-
| `template.js` | Component HTML template |
161-
| `styles.js` | Component scoped styles |
162179

163180
## Key Dependencies
164181

0 commit comments

Comments
 (0)