dinou 1.9.3 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +31 -5
- package/dinou/render-html.js +24 -2
- package/dinou/server.js +24 -2
- package/package.json +1 -1
- package/webpack.config.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
7
7
|
|
|
8
|
+
## [1.10.0]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Support for additional assets or media file extensions (image, audio, and video).
|
|
13
|
+
|
|
8
14
|
## [1.9.3]
|
|
9
15
|
|
|
10
16
|
### Changed
|
package/README.md
CHANGED
|
@@ -110,7 +110,7 @@ dinou main features are:
|
|
|
110
110
|
|
|
111
111
|
- [Styles (Tailwind.css, .module.css, and .css)](#styles-tailwindcss-modulecss-and-css)
|
|
112
112
|
|
|
113
|
-
- [
|
|
113
|
+
- [Assets or media files (image, video, and sound)](#assets-or-media-files-image-video-and-sound)
|
|
114
114
|
|
|
115
115
|
- [Import alias (e.g. `"@/..."`)](#import-alias-eg-)
|
|
116
116
|
|
|
@@ -1142,9 +1142,11 @@ dinou is ready to use Tailwind.css, `.module.css`, and `.css` styles. All styles
|
|
|
1142
1142
|
import "./page.module.css";
|
|
1143
1143
|
```
|
|
1144
1144
|
|
|
1145
|
-
##
|
|
1145
|
+
## Assets or media files (image, video, and sound)
|
|
1146
1146
|
|
|
1147
|
-
dinou
|
|
1147
|
+
dinou supports the use of assets in your components. Supported file extensions are: `.png`, `.jpeg`, `.jpg`, `.gif`, `.svg`, `.webp`, `.avif`, `.ico`, `.mp4`, `.webm`, `.ogg`, `.mov`, `.avi`, `.mkv`, `.mp3`, `.wav`, `.flac`, `.m4a`, `.aac`, `.mjpeg`, and `.mjpg`.
|
|
1148
|
+
|
|
1149
|
+
To use an asset in your component just import it as a default import:
|
|
1148
1150
|
|
|
1149
1151
|
```typescript
|
|
1150
1152
|
// src/component.tsx
|
|
@@ -1157,10 +1159,10 @@ export default function Component() {
|
|
|
1157
1159
|
}
|
|
1158
1160
|
```
|
|
1159
1161
|
|
|
1160
|
-
**Only
|
|
1162
|
+
**Only assets imported under `"use client"` directive will be detected by Webpack and generated in webpack folder**. If you use **server components**, then you must create an additional file (e.g. `assets.ts`) with the `"use client"` directive and import there the assets too:
|
|
1161
1163
|
|
|
1162
1164
|
```typescript
|
|
1163
|
-
// src/
|
|
1165
|
+
// src/assets.ts
|
|
1164
1166
|
"use client";
|
|
1165
1167
|
|
|
1166
1168
|
import "./image.png";
|
|
@@ -1175,6 +1177,30 @@ export default async function Component() {
|
|
|
1175
1177
|
}
|
|
1176
1178
|
```
|
|
1177
1179
|
|
|
1180
|
+
For typescript, you should create a declaration file like this:
|
|
1181
|
+
|
|
1182
|
+
```typescript
|
|
1183
|
+
// src/assets.d.ts
|
|
1184
|
+
declare module "*.jpeg" {
|
|
1185
|
+
const value: string;
|
|
1186
|
+
export default value;
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
declare module "*.jpg" {
|
|
1190
|
+
const value: string;
|
|
1191
|
+
export default value;
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
declare module "*.png" {
|
|
1195
|
+
const value: string;
|
|
1196
|
+
export default value;
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
// and continue with the rest of supported file extensions
|
|
1200
|
+
```
|
|
1201
|
+
|
|
1202
|
+
If you miss a certain file extension you can eject and customize dinou to meet your requirements. Just eject and add the extension in these three places: `webpack.config.js`, `dinou/server.js`, and `dinou/render-html.js`. Just look for the place were all the extensions are mentioned and add yours in these three files.
|
|
1203
|
+
|
|
1178
1204
|
## Import alias (e.g. `"@/..."`)
|
|
1179
1205
|
|
|
1180
1206
|
dinou is ready to support import alias, as `import some from "@/..."`. If you want to use them just define the options in `tsconfig.json` or `jsconfig.json`:
|
package/dinou/render-html.js
CHANGED
|
@@ -15,12 +15,34 @@ require("css-modules-require-hook")({
|
|
|
15
15
|
generateScopedName: createScopedName,
|
|
16
16
|
});
|
|
17
17
|
addHook({
|
|
18
|
-
extensions: [
|
|
18
|
+
extensions: [
|
|
19
|
+
"png",
|
|
20
|
+
"jpg",
|
|
21
|
+
"jpeg",
|
|
22
|
+
"gif",
|
|
23
|
+
"svg",
|
|
24
|
+
"webp",
|
|
25
|
+
"avif",
|
|
26
|
+
"ico",
|
|
27
|
+
"mp4",
|
|
28
|
+
"webm",
|
|
29
|
+
"ogg",
|
|
30
|
+
"mov",
|
|
31
|
+
"avi",
|
|
32
|
+
"mkv",
|
|
33
|
+
"mp3",
|
|
34
|
+
"wav",
|
|
35
|
+
"flac",
|
|
36
|
+
"m4a",
|
|
37
|
+
"aac",
|
|
38
|
+
"mjpeg",
|
|
39
|
+
"mjpg",
|
|
40
|
+
],
|
|
19
41
|
name: function (localName, filepath) {
|
|
20
42
|
const result = createScopedName(localName, filepath);
|
|
21
43
|
return result + ".[ext]";
|
|
22
44
|
},
|
|
23
|
-
publicPath: "/
|
|
45
|
+
publicPath: "/assets/",
|
|
24
46
|
});
|
|
25
47
|
|
|
26
48
|
const { renderToPipeableStream } = require("react-dom/server");
|
package/dinou/server.js
CHANGED
|
@@ -24,12 +24,34 @@ require("css-modules-require-hook")({
|
|
|
24
24
|
generateScopedName: createScopedName,
|
|
25
25
|
});
|
|
26
26
|
addHook({
|
|
27
|
-
extensions: [
|
|
27
|
+
extensions: [
|
|
28
|
+
"png",
|
|
29
|
+
"jpg",
|
|
30
|
+
"jpeg",
|
|
31
|
+
"gif",
|
|
32
|
+
"svg",
|
|
33
|
+
"webp",
|
|
34
|
+
"avif",
|
|
35
|
+
"ico",
|
|
36
|
+
"mp4",
|
|
37
|
+
"webm",
|
|
38
|
+
"ogg",
|
|
39
|
+
"mov",
|
|
40
|
+
"avi",
|
|
41
|
+
"mkv",
|
|
42
|
+
"mp3",
|
|
43
|
+
"wav",
|
|
44
|
+
"flac",
|
|
45
|
+
"m4a",
|
|
46
|
+
"aac",
|
|
47
|
+
"mjpeg",
|
|
48
|
+
"mjpg",
|
|
49
|
+
],
|
|
28
50
|
name: function (localName, filepath) {
|
|
29
51
|
const result = createScopedName(localName, filepath);
|
|
30
52
|
return result + ".[ext]";
|
|
31
53
|
},
|
|
32
|
-
publicPath: "/
|
|
54
|
+
publicPath: "/assets/",
|
|
33
55
|
});
|
|
34
56
|
const generateStatic = require("./generate-static.js");
|
|
35
57
|
const renderAppToHtml = require("./render-app-to-html.js");
|
package/package.json
CHANGED
package/webpack.config.js
CHANGED
|
@@ -97,7 +97,7 @@ module.exports = {
|
|
|
97
97
|
],
|
|
98
98
|
},
|
|
99
99
|
{
|
|
100
|
-
test: /\.(png|jpe?g|gif|svg|webp)$/i,
|
|
100
|
+
test: /\.(png|jpe?g|gif|svg|webp|avif|ico|mp4|webm|ogg|mov|avi|mkv|mp3|wav|flac|m4a|aac|mjpeg|mjpg)$/i,
|
|
101
101
|
type: "asset/resource",
|
|
102
102
|
generator: {
|
|
103
103
|
filename: (pathData) => {
|
|
@@ -111,7 +111,7 @@ module.exports = {
|
|
|
111
111
|
);
|
|
112
112
|
const scoped = createScopedName(base, resourcePath);
|
|
113
113
|
|
|
114
|
-
return `/
|
|
114
|
+
return `/assets/${scoped}[ext]`;
|
|
115
115
|
},
|
|
116
116
|
publicPath: "",
|
|
117
117
|
},
|