@navita/vite-plugin 3.0.0-next.2 → 3.0.0-next.3

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/index.cjs CHANGED
@@ -88,11 +88,13 @@ function navita(options) {
88
88
  }];
89
89
  } },
90
90
  renderChunk(_, chunk) {
91
- if (cssEmitted) return;
91
+ if (this.environment?.name !== "client" || cssEmitted) return;
92
+ const css = getRenderer()?.engine.renderCssToString();
93
+ if (!css) return;
92
94
  chunk.viteMetadata.importedCss.add(this.getFileName(this.emitFile({
93
95
  name: "navita.css",
94
96
  type: "asset",
95
- source: getRenderer()?.engine.renderCssToString()
97
+ source: css
96
98
  })));
97
99
  cssEmitted = true;
98
100
  }
@@ -103,18 +105,16 @@ function navita(options) {
103
105
  updateTimer = setTimeout(() => {
104
106
  const { moduleGraph, ws } = server;
105
107
  const mod = moduleGraph.getModuleById(RESOLVED_VIRTUAL_MODULE_ID);
106
- if (mod) {
107
- moduleGraph.invalidateModule(mod);
108
- ws.send({
109
- type: "update",
110
- updates: [{
111
- type: "css-update",
112
- path: `/${VIRTUAL_MODULE_ID}`,
113
- acceptedPath: `/${VIRTUAL_MODULE_ID}`,
114
- timestamp: Date.now()
115
- }]
116
- });
117
- }
108
+ if (mod) moduleGraph.invalidateModule(mod);
109
+ ws.send({
110
+ type: "update",
111
+ updates: [{
112
+ type: "css-update",
113
+ path: `/${VIRTUAL_MODULE_ID}`,
114
+ acceptedPath: `/${VIRTUAL_MODULE_ID}`,
115
+ timestamp: Date.now()
116
+ }]
117
+ });
118
118
  }, 20);
119
119
  }
120
120
  }
package/index.mjs CHANGED
@@ -88,11 +88,13 @@ function navita(options) {
88
88
  }];
89
89
  } },
90
90
  renderChunk(_, chunk) {
91
- if (cssEmitted) return;
91
+ if (this.environment?.name !== "client" || cssEmitted) return;
92
+ const css = getRenderer()?.engine.renderCssToString();
93
+ if (!css) return;
92
94
  chunk.viteMetadata.importedCss.add(this.getFileName(this.emitFile({
93
95
  name: "navita.css",
94
96
  type: "asset",
95
- source: getRenderer()?.engine.renderCssToString()
97
+ source: css
96
98
  })));
97
99
  cssEmitted = true;
98
100
  }
@@ -103,18 +105,16 @@ function navita(options) {
103
105
  updateTimer = setTimeout(() => {
104
106
  const { moduleGraph, ws } = server;
105
107
  const mod = moduleGraph.getModuleById(RESOLVED_VIRTUAL_MODULE_ID);
106
- if (mod) {
107
- moduleGraph.invalidateModule(mod);
108
- ws.send({
109
- type: "update",
110
- updates: [{
111
- type: "css-update",
112
- path: `/${VIRTUAL_MODULE_ID}`,
113
- acceptedPath: `/${VIRTUAL_MODULE_ID}`,
114
- timestamp: Date.now()
115
- }]
116
- });
117
- }
108
+ if (mod) moduleGraph.invalidateModule(mod);
109
+ ws.send({
110
+ type: "update",
111
+ updates: [{
112
+ type: "css-update",
113
+ path: `/${VIRTUAL_MODULE_ID}`,
114
+ acceptedPath: `/${VIRTUAL_MODULE_ID}`,
115
+ timestamp: Date.now()
116
+ }]
117
+ });
118
118
  }, 20);
119
119
  }
120
120
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navita/vite-plugin",
3
- "version": "3.0.0-next.2",
3
+ "version": "3.0.0-next.3",
4
4
  "description": "Navita Vite Plugin",
5
5
  "keywords": [
6
6
  "vite",
@@ -27,8 +27,8 @@
27
27
  }
28
28
  },
29
29
  "dependencies": {
30
- "@navita/core": "3.0.0-next.2",
31
- "@navita/css": "3.0.0-next.2"
30
+ "@navita/core": "3.0.0-next.3",
31
+ "@navita/css": "3.0.0-next.3"
32
32
  },
33
33
  "license": "MIT",
34
34
  "author": "Eagerpatch",
package/rwsdk.cjs CHANGED
@@ -16,6 +16,14 @@ function navitaRwsdk(options) {
16
16
  projectRootDir = config.root;
17
17
  base = config.base;
18
18
  },
19
+ configureServer(server) {
20
+ server.middlewares.use((req, res, next) => {
21
+ if (req.url?.split("?")[0] !== `/virtual:navita.css`) return next();
22
+ res.setHeader("Content-Type", "text/css");
23
+ res.setHeader("Cache-Control", "no-cache");
24
+ res.end(require_index.getRenderer()?.engine.renderCssToString() ?? "");
25
+ });
26
+ },
19
27
  async renderChunk(code) {
20
28
  if (this.environment?.name !== "worker" || process.env.RWSDK_BUILD_PASS !== "linker") return null;
21
29
  const manifestPath = node_path.resolve(projectRootDir, "dist", "client", ".vite", "manifest.json");
package/rwsdk.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import "node:path";
2
2
  import "node:url";
3
3
  import.meta.url;
4
- import { VIRTUAL_MODULE_ID, navita } from "./index.mjs";
4
+ import { VIRTUAL_MODULE_ID, getRenderer, navita } from "./index.mjs";
5
5
  import * as fsp from "node:fs/promises";
6
6
  import * as path from "node:path";
7
7
  //#region src/rwsdk.ts
@@ -15,6 +15,14 @@ function navitaRwsdk(options) {
15
15
  projectRootDir = config.root;
16
16
  base = config.base;
17
17
  },
18
+ configureServer(server) {
19
+ server.middlewares.use((req, res, next) => {
20
+ if (req.url?.split("?")[0] !== `/virtual:navita.css`) return next();
21
+ res.setHeader("Content-Type", "text/css");
22
+ res.setHeader("Cache-Control", "no-cache");
23
+ res.end(getRenderer()?.engine.renderCssToString() ?? "");
24
+ });
25
+ },
18
26
  async renderChunk(code) {
19
27
  if (this.environment?.name !== "worker" || process.env.RWSDK_BUILD_PASS !== "linker") return null;
20
28
  const manifestPath = path.resolve(projectRootDir, "dist", "client", ".vite", "manifest.json");