@nikala-ui/cli 0.11.0-nightly.33a9bda → 0.11.0-nightly.b01fa01
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.
|
@@ -12,36 +12,43 @@ export async function configureAliases(cwd) {
|
|
|
12
12
|
if (await fs.pathExists(targetConfigPath)) {
|
|
13
13
|
let configContent = await fs.readFile(targetConfigPath, "utf-8");
|
|
14
14
|
let modified = false;
|
|
15
|
+
// 1. Inject Tailwind CSS v4 Vite plugin if missing
|
|
15
16
|
if (!configContent.includes("@tailwindcss/vite")) {
|
|
16
17
|
configContent = `import tailwindcss from "@tailwindcss/vite";\n${configContent}`;
|
|
17
18
|
if (configContent.includes("plugins: [")) {
|
|
18
19
|
configContent = configContent.replace("plugins: [", "plugins: [\n tailwindcss(), ");
|
|
20
|
+
modified = true;
|
|
19
21
|
}
|
|
20
|
-
else
|
|
21
|
-
|
|
22
|
+
else {
|
|
23
|
+
const defineConfigRegex = /(defineConfig\s*\(\s*(?:async\s*)?(?:\([^)]*\)\s*=>\s*)?\{)/;
|
|
24
|
+
if (defineConfigRegex.test(configContent)) {
|
|
25
|
+
configContent = configContent.replace(defineConfigRegex, "$1\n plugins: [tailwindcss()],");
|
|
26
|
+
modified = true;
|
|
27
|
+
}
|
|
22
28
|
}
|
|
23
|
-
modified = true;
|
|
24
29
|
}
|
|
30
|
+
// 2. Inject path alias (@ -> ./src)
|
|
25
31
|
if (!configContent.includes('"@"') && !configContent.includes("'@'")) {
|
|
26
32
|
if (!configContent.includes('import path from "node:path"') && !configContent.includes('import path from "path"')) {
|
|
27
33
|
configContent = `import path from "node:path";\n${configContent}`;
|
|
28
34
|
}
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
const defineConfigRegex = /(defineConfig\s*\(\s*(?:async\s*)?(?:\([^)]*\)\s*=>\s*)?\{)/;
|
|
36
|
+
if (defineConfigRegex.test(configContent)) {
|
|
37
|
+
configContent = configContent.replace(defineConfigRegex, `$1\n resolve: {\n alias: {\n "@": path.resolve(process.cwd(), "./src"),\n },\n },`);
|
|
38
|
+
modified = true;
|
|
31
39
|
}
|
|
32
|
-
modified = true;
|
|
33
40
|
}
|
|
34
41
|
if (modified) {
|
|
35
42
|
await fs.writeFile(targetConfigPath, configContent, "utf-8");
|
|
36
43
|
console.log(pc.green(`✓ Configured Tailwind CSS v4 plugin and path alias in ${path.basename(targetConfigPath)}`));
|
|
37
44
|
}
|
|
38
45
|
}
|
|
46
|
+
// 3. Configure tsconfig.json path mappings (@/* -> ./src/*)
|
|
39
47
|
const tsconfigPath = path.join(cwd, "tsconfig.json");
|
|
40
48
|
if (await fs.pathExists(tsconfigPath)) {
|
|
41
49
|
const tsconfig = await readTsConfig(cwd);
|
|
42
50
|
if (tsconfig) {
|
|
43
51
|
tsconfig.compilerOptions = tsconfig.compilerOptions || {};
|
|
44
|
-
tsconfig.compilerOptions.baseUrl = ".";
|
|
45
52
|
tsconfig.compilerOptions.paths = tsconfig.compilerOptions.paths || {};
|
|
46
53
|
// Correct path mapping with leading relative dot ./src/*
|
|
47
54
|
tsconfig.compilerOptions.paths["@/*"] = ["./src/*"];
|