@navita/vite-plugin 2.0.0 → 2.0.1
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/package.json +1 -1
- package/remix.cjs +19 -24
- package/remix.mjs +20 -25
package/package.json
CHANGED
package/remix.cjs
CHANGED
|
@@ -22,37 +22,23 @@ function _interopNamespaceDefault(e) {
|
|
|
22
22
|
|
|
23
23
|
var crypto__namespace = /*#__PURE__*/_interopNamespaceDefault(crypto);
|
|
24
24
|
|
|
25
|
+
const remixServerBuildId = '\0virtual:remix/server-build';
|
|
25
26
|
let cssFileName;
|
|
26
27
|
function navitaRemix(options) {
|
|
27
|
-
let
|
|
28
|
+
let isProduction = false;
|
|
28
29
|
const { renderChunk , ...navitaVite } = index.navita(options);
|
|
29
30
|
return [
|
|
30
31
|
navitaVite,
|
|
31
32
|
{
|
|
32
33
|
name: 'navita-remix',
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
build.routes.root.module = {
|
|
42
|
-
...module,
|
|
43
|
-
links: ()=>[
|
|
44
|
-
...module.links(),
|
|
45
|
-
{
|
|
46
|
-
rel: 'stylesheet',
|
|
47
|
-
href: `/${index.VIRTUAL_MODULE_ID}`
|
|
48
|
-
}
|
|
49
|
-
]
|
|
50
|
-
};
|
|
51
|
-
} catch (e) {
|
|
52
|
-
console.error(e);
|
|
53
|
-
}
|
|
54
|
-
next();
|
|
55
|
-
});
|
|
34
|
+
configResolved (config) {
|
|
35
|
+
isProduction = config.mode === 'production';
|
|
36
|
+
},
|
|
37
|
+
transform (code, id) {
|
|
38
|
+
if (isProduction || id !== remixServerBuildId) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
return `${code}\n${remixServerBuildExtension}`;
|
|
56
42
|
},
|
|
57
43
|
renderChunk (_, chunk) {
|
|
58
44
|
if (chunk.name === "root") {
|
|
@@ -80,5 +66,14 @@ function navitaRemix(options) {
|
|
|
80
66
|
}
|
|
81
67
|
];
|
|
82
68
|
}
|
|
69
|
+
const remixServerBuildExtension = `
|
|
70
|
+
routes.root.module = {
|
|
71
|
+
...route0,
|
|
72
|
+
links: () => [
|
|
73
|
+
...(route0.links ? route0.links() : []),
|
|
74
|
+
{ rel: 'stylesheet', href: '/${index.VIRTUAL_MODULE_ID}' },
|
|
75
|
+
],
|
|
76
|
+
};
|
|
77
|
+
`;
|
|
83
78
|
|
|
84
79
|
exports.navitaRemix = navitaRemix;
|
package/remix.mjs
CHANGED
|
@@ -1,37 +1,23 @@
|
|
|
1
1
|
import * as crypto from 'node:crypto';
|
|
2
|
-
import { navita,
|
|
2
|
+
import { navita, getRenderer, VIRTUAL_MODULE_ID } from './index.mjs';
|
|
3
3
|
|
|
4
|
+
const remixServerBuildId = '\0virtual:remix/server-build';
|
|
4
5
|
let cssFileName;
|
|
5
6
|
function navitaRemix(options) {
|
|
6
|
-
let
|
|
7
|
+
let isProduction = false;
|
|
7
8
|
const { renderChunk , ...navitaVite } = navita(options);
|
|
8
9
|
return [
|
|
9
10
|
navitaVite,
|
|
10
11
|
{
|
|
11
12
|
name: 'navita-remix',
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
build.routes.root.module = {
|
|
21
|
-
...module,
|
|
22
|
-
links: ()=>[
|
|
23
|
-
...module.links(),
|
|
24
|
-
{
|
|
25
|
-
rel: 'stylesheet',
|
|
26
|
-
href: `/${VIRTUAL_MODULE_ID}`
|
|
27
|
-
}
|
|
28
|
-
]
|
|
29
|
-
};
|
|
30
|
-
} catch (e) {
|
|
31
|
-
console.error(e);
|
|
32
|
-
}
|
|
33
|
-
next();
|
|
34
|
-
});
|
|
13
|
+
configResolved (config) {
|
|
14
|
+
isProduction = config.mode === 'production';
|
|
15
|
+
},
|
|
16
|
+
transform (code, id) {
|
|
17
|
+
if (isProduction || id !== remixServerBuildId) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
return `${code}\n${remixServerBuildExtension}`;
|
|
35
21
|
},
|
|
36
22
|
renderChunk (_, chunk) {
|
|
37
23
|
if (chunk.name === "root") {
|
|
@@ -59,5 +45,14 @@ function navitaRemix(options) {
|
|
|
59
45
|
}
|
|
60
46
|
];
|
|
61
47
|
}
|
|
48
|
+
const remixServerBuildExtension = `
|
|
49
|
+
routes.root.module = {
|
|
50
|
+
...route0,
|
|
51
|
+
links: () => [
|
|
52
|
+
...(route0.links ? route0.links() : []),
|
|
53
|
+
{ rel: 'stylesheet', href: '/${VIRTUAL_MODULE_ID}' },
|
|
54
|
+
],
|
|
55
|
+
};
|
|
56
|
+
`;
|
|
62
57
|
|
|
63
58
|
export { navitaRemix };
|