-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathbuild-config.shared.js
More file actions
59 lines (49 loc) · 1.9 KB
/
build-config.shared.js
File metadata and controls
59 lines (49 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* Build configuration for Vite
* Single source of truth for legacy module resolution
*/
import path from "path";
import { fileURLToPath } from "url";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const scriptsBase = path.join(__dirname, "src");
const libsBase = path.join(scriptsBase, "libs");
const styleBase = path.join(scriptsBase, "style");
// Legacy exact-match aliases
export const legacyAliases = {
// Core libraries
// Note: jquery is NOT aliased - it resolves to node_modules/jquery directly
// The global setup (window.$, window.jQuery) is done in libs.js
jqueryVendor: path.join(libsBase, "jquery/jquery.js"),
storemodern: path.join(__dirname, "node_modules/store/dist/store.modern.js"),
// Vue - use @vue/compat for Vue 3 compatibility mode
vue: path.join(__dirname, "node_modules/@vue/compat"),
// Build config
config: path.join(scriptsBase, "config", process.env.NODE_ENV || "development") + ".js",
app: path.join(scriptsBase, "app.js"),
};
// Module resolution paths
export const modulePaths = [scriptsBase, "node_modules", styleBase];
// File extensions for resolution
export const extensions = [".ts", ".js", ".json", ".vue", ".scss"];
/**
* Get Vite-format aliases (uses regex patterns for exact matches)
*/
export function getViteAliases() {
const viteAliases = [
// @ alias
{ find: "@", replacement: scriptsBase },
];
// Add exact match patterns
for (const [key, value] of Object.entries(legacyAliases)) {
viteAliases.push({
find: new RegExp(`^${key}$`),
replacement: path.isAbsolute(value) ? value : path.join(__dirname, value),
});
}
// Add prefix patterns for legacy paths
viteAliases.push(
{ find: /^libs\//, replacement: libsBase + "/" },
{ find: /^ui\//, replacement: path.join(scriptsBase, "ui") + "/" },
);
return viteAliases;
}