-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathesbuild.config.js
More file actions
89 lines (83 loc) · 3.23 KB
/
esbuild.config.js
File metadata and controls
89 lines (83 loc) · 3.23 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
const path = require("path");
const { sassPlugin } = require("esbuild-sass-plugin");
const vuePlugin = require("esbuild-vue");
// List all of our entry points with output names
const entryPoints = {
application: "app/javascript/packs/application.js", // This imports application.scss
"bootstrap-vue": "app/javascript/bootstrap-vue.scss",
navbar: "app/javascript/packs/navbar.js",
toaster: "app/javascript/packs/toaster.js",
login: "app/javascript/packs/login.js",
projects: "app/javascript/packs/projects.js",
project: "app/javascript/packs/project.js",
project_components: "app/javascript/packs/project_components.js",
project_component: "app/javascript/packs/project_component.js",
project_triage: "app/javascript/packs/project_triage.js",
component_triage: "app/javascript/packs/component_triage.js",
component_settings: "app/javascript/packs/component_settings.js",
released_component: "app/javascript/packs/released_component.js",
rules: "app/javascript/packs/rules.js",
security_requirements_guides: "app/javascript/packs/security_requirements_guides.js",
srg: "app/javascript/packs/srg.js",
stig: "app/javascript/packs/stig.js",
stigs: "app/javascript/packs/stigs.js",
users: "app/javascript/packs/users.js",
user_profile: "app/javascript/packs/user_profile.js",
user_password: "app/javascript/packs/user_password.js",
user_activity: "app/javascript/packs/user_activity.js",
user_comments: "app/javascript/packs/user_comments.js",
};
// Check if we're in watch mode
const watch = process.argv.includes("--watch");
const buildOptions = {
entryPoints,
bundle: true,
outdir: "app/assets/builds",
absWorkingDir: path.resolve(__dirname),
metafile: true, // Useful for debugging dependencies
plugins: [
sassPlugin({
loadPaths: ["node_modules"],
style: "expanded", // Use expanded style for better debugging
}),
vuePlugin({
enableDevtools: true, // Enable Vue devtools for development
cssInline: true, // Extract CSS for better loading performance
useFullVue: true, // Use full Vue build with template compiler
}),
],
loader: {
".png": "file",
".jpg": "file",
".svg": "file",
".woff": "file",
".woff2": "file",
".ttf": "file",
".eot": "file",
},
// Make files available at their expected paths with correct prefix
publicPath: "/assets",
sourcemap: true,
format: "iife", // IIFE format for Vue 2 browser compatibility
define: {
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || "development"),
__VUE_OPTIONS_API__: "true", // Enable Vue Options API
__VUE_PROD_DEVTOOLS__: "true", // Enable Vue devtools even in production
},
alias: {
vue: "vue/dist/vue.esm.js", // Use the full build with template compiler
},
// Add inject option to automatically add needed polyfills
inject: ["./node_modules/bootstrap/dist/js/bootstrap.js"],
// Fix for CSS paths - allow both node_modules and relative paths
resolveExtensions: [".js", ".json", ".vue", ".css", ".scss"],
// Standard asset naming with content hash for proper caching
assetNames: "[name]-[hash]",
};
// Add watch option only if in watch mode
if (watch) {
buildOptions.watch = true;
}
require("esbuild")
.build(buildOptions)
.catch(() => process.exit(1));