@lark-apaas/fullstack-vite-preset 1.0.15 → 1.0.17
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.
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* Vite plugin to handle inspector CSS imports
|
|
4
|
+
*
|
|
5
|
+
* Creates an empty inspector.dev.css stub file if it doesn't exist.
|
|
6
|
+
* This is needed because:
|
|
7
|
+
* 1. @lark-apaas/client-toolkit imports @/inspector.dev.css
|
|
8
|
+
* 2. Vite's internal postcss-import processes @import statements before
|
|
9
|
+
* custom plugins can intercept them
|
|
10
|
+
* 3. The inspector UI injects its own styles at runtime, so this file
|
|
11
|
+
* can be empty
|
|
12
|
+
*
|
|
13
|
+
* In production mode, the stub file is cleaned up after build.
|
|
14
|
+
* In development mode, the stub file is kept (or user can provide real CSS).
|
|
15
|
+
*/
|
|
16
|
+
export declare function inspectorCssPlugin(options: {
|
|
17
|
+
isDev: boolean;
|
|
18
|
+
}): Plugin;
|
|
19
|
+
//# sourceMappingURL=inspector-css-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspector-css-plugin.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/inspector-css-plugin.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,MAAM,CAAC;AAKnD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,CA8CtE"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.inspectorCssPlugin = inspectorCssPlugin;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const INSPECTOR_CSS_FILENAME = 'inspector.dev.css';
|
|
10
|
+
const EMPTY_CSS_CONTENT = '/* Inspector CSS - placeholder for postcss-import */\n';
|
|
11
|
+
/**
|
|
12
|
+
* Vite plugin to handle inspector CSS imports
|
|
13
|
+
*
|
|
14
|
+
* Creates an empty inspector.dev.css stub file if it doesn't exist.
|
|
15
|
+
* This is needed because:
|
|
16
|
+
* 1. @lark-apaas/client-toolkit imports @/inspector.dev.css
|
|
17
|
+
* 2. Vite's internal postcss-import processes @import statements before
|
|
18
|
+
* custom plugins can intercept them
|
|
19
|
+
* 3. The inspector UI injects its own styles at runtime, so this file
|
|
20
|
+
* can be empty
|
|
21
|
+
*
|
|
22
|
+
* In production mode, the stub file is cleaned up after build.
|
|
23
|
+
* In development mode, the stub file is kept (or user can provide real CSS).
|
|
24
|
+
*/
|
|
25
|
+
function inspectorCssPlugin(options) {
|
|
26
|
+
const { isDev } = options;
|
|
27
|
+
let createdStubFile = null;
|
|
28
|
+
return {
|
|
29
|
+
name: 'vite-inspector-css',
|
|
30
|
+
enforce: 'pre',
|
|
31
|
+
configResolved(config) {
|
|
32
|
+
const rootDir = config.root || process.cwd();
|
|
33
|
+
const stubPath = path_1.default.resolve(rootDir, 'client/src', INSPECTOR_CSS_FILENAME);
|
|
34
|
+
// Create stub file if it doesn't exist (both dev and production)
|
|
35
|
+
// This prevents Vite's internal postcss-import from failing
|
|
36
|
+
if (!fs_1.default.existsSync(stubPath)) {
|
|
37
|
+
try {
|
|
38
|
+
// Ensure directory exists
|
|
39
|
+
const dir = path_1.default.dirname(stubPath);
|
|
40
|
+
if (!fs_1.default.existsSync(dir)) {
|
|
41
|
+
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
42
|
+
}
|
|
43
|
+
fs_1.default.writeFileSync(stubPath, EMPTY_CSS_CONTENT);
|
|
44
|
+
// Only track for cleanup in production mode
|
|
45
|
+
if (!isDev) {
|
|
46
|
+
createdStubFile = stubPath;
|
|
47
|
+
}
|
|
48
|
+
console.log(`[vite-inspector-css] Created stub: ${stubPath}`);
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
console.warn(`[vite-inspector-css] Could not create stub file: ${e}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
buildEnd() {
|
|
56
|
+
// Clean up the stub file after production build completes
|
|
57
|
+
if (createdStubFile && fs_1.default.existsSync(createdStubFile)) {
|
|
58
|
+
try {
|
|
59
|
+
fs_1.default.unlinkSync(createdStubFile);
|
|
60
|
+
console.log(`[vite-inspector-css] Cleaned up stub: ${createdStubFile}`);
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
console.warn(`[vite-inspector-css] Could not clean up stub file: ${e}`);
|
|
64
|
+
}
|
|
65
|
+
createdStubFile = null;
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=inspector-css-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspector-css-plugin.js","sourceRoot":"","sources":["../../src/vite-plugins/inspector-css-plugin.ts"],"names":[],"mappings":";;;;;AAqBA,gDA8CC;AAnED,4CAAoB;AACpB,gDAAwB;AAGxB,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AACnD,MAAM,iBAAiB,GAAG,wDAAwD,CAAC;AAEnF;;;;;;;;;;;;;GAaG;AACH,SAAgB,kBAAkB,CAAC,OAA2B;IAC5D,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAC1B,IAAI,eAAe,GAAkB,IAAI,CAAC;IAE1C,OAAO;QACL,IAAI,EAAE,oBAAoB;QAC1B,OAAO,EAAE,KAAK;QAEd,cAAc,CAAC,MAAsB;YACnC,MAAM,OAAO,GAAG,MAAM,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