@gxp-dev/tools 2.0.92 → 2.0.94
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/bin/lib/commands/init.js +2 -0
- package/bin/lib/constants.js +12 -0
- package/bin/lib/utils/files.js +32 -0
- package/package.json +1 -1
- package/runtime/stores/gxpPortalConfigStore.js +1 -1
- package/runtime/vite.config.js +43 -0
- package/template/app-manifest.json +1 -0
- package/template/env.example +1 -1
- package/template/theme-layouts/PrivateLayout.vue +10 -0
- package/template/theme-layouts/PublicLayout.vue +10 -0
- package/template/theme-layouts/SystemLayout.vue +10 -0
package/bin/lib/commands/init.js
CHANGED
|
@@ -29,6 +29,7 @@ const {
|
|
|
29
29
|
safeCopyFile,
|
|
30
30
|
createPackageJson,
|
|
31
31
|
updateAppManifest,
|
|
32
|
+
ensureBaseFramework,
|
|
32
33
|
installDependencies,
|
|
33
34
|
updateExistingProject,
|
|
34
35
|
ensureMkcertInstalled,
|
|
@@ -721,6 +722,7 @@ async function initCommand(argv) {
|
|
|
721
722
|
console.log("Updating existing project...")
|
|
722
723
|
updateExistingProject(projectPath)
|
|
723
724
|
copyBundleFiles(projectPath, paths, false)
|
|
725
|
+
ensureBaseFramework(projectPath)
|
|
724
726
|
console.log("✅ Project updated!")
|
|
725
727
|
return
|
|
726
728
|
}
|
package/bin/lib/constants.js
CHANGED
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
const isWin = process.platform === "win32"
|
|
9
9
|
const exportCmd = isWin ? "set" : "export"
|
|
10
10
|
|
|
11
|
+
// Base CSS framework loaded by theme-layouts during development.
|
|
12
|
+
// Versioned here so the same value lands in package.json devDependencies
|
|
13
|
+
// AND the app-manifest's baseFramework field (platform reads the manifest
|
|
14
|
+
// to know which CSS framework to provide for the live plugin).
|
|
15
|
+
const TAILWIND_VERSION = "^4.3.0"
|
|
16
|
+
|
|
11
17
|
// Required dependencies for GxP projects
|
|
12
18
|
const REQUIRED_DEPENDENCIES = {
|
|
13
19
|
dotenv: "^16.4.5",
|
|
@@ -23,8 +29,12 @@ const REQUIRED_DEV_DEPENDENCIES = {
|
|
|
23
29
|
vitest: "^4.1.5",
|
|
24
30
|
"@vue/test-utils": "^2.4.6",
|
|
25
31
|
"happy-dom": "^15.11.0",
|
|
32
|
+
tailwindcss: TAILWIND_VERSION,
|
|
33
|
+
"@tailwindcss/vite": TAILWIND_VERSION,
|
|
26
34
|
}
|
|
27
35
|
|
|
36
|
+
const BASE_FRAMEWORK = `tailwindcss@${TAILWIND_VERSION}`
|
|
37
|
+
|
|
28
38
|
// Default scripts for package.json
|
|
29
39
|
const DEFAULT_SCRIPTS = {
|
|
30
40
|
dev: "gxdev dev --cli",
|
|
@@ -131,4 +141,6 @@ module.exports = {
|
|
|
131
141
|
DEFAULT_PORTS,
|
|
132
142
|
PACKAGE_NAME,
|
|
133
143
|
ENVIRONMENT_URLS,
|
|
144
|
+
TAILWIND_VERSION,
|
|
145
|
+
BASE_FRAMEWORK,
|
|
134
146
|
}
|
package/bin/lib/utils/files.js
CHANGED
|
@@ -11,6 +11,7 @@ const {
|
|
|
11
11
|
REQUIRED_DEPENDENCIES,
|
|
12
12
|
REQUIRED_DEV_DEPENDENCIES,
|
|
13
13
|
DEFAULT_SCRIPTS,
|
|
14
|
+
BASE_FRAMEWORK,
|
|
14
15
|
} = require("../constants")
|
|
15
16
|
const { loadGlobalConfig } = require("./paths")
|
|
16
17
|
|
|
@@ -89,6 +90,9 @@ function updateAppManifest(projectPath, projectName, description = "") {
|
|
|
89
90
|
manifest.description = `GxP Plugin: ${projectName}`
|
|
90
91
|
}
|
|
91
92
|
|
|
93
|
+
// Tell the platform which base CSS framework the layouts load.
|
|
94
|
+
manifest.baseFramework = BASE_FRAMEWORK
|
|
95
|
+
|
|
92
96
|
// Update strings with project name
|
|
93
97
|
if (manifest.strings && manifest.strings.default) {
|
|
94
98
|
manifest.strings.default.welcome_text = `Welcome to ${projectName}`
|
|
@@ -101,6 +105,33 @@ function updateAppManifest(projectPath, projectName, description = "") {
|
|
|
101
105
|
}
|
|
102
106
|
}
|
|
103
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Ensures app-manifest.json has the current baseFramework value.
|
|
110
|
+
* Used during existing-project updates where the manifest file is not overwritten.
|
|
111
|
+
* @param {string} projectPath - Path to project directory
|
|
112
|
+
*/
|
|
113
|
+
function ensureBaseFramework(projectPath) {
|
|
114
|
+
const manifestPath = path.join(projectPath, "app-manifest.json")
|
|
115
|
+
if (!fs.existsSync(manifestPath)) {
|
|
116
|
+
return
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
try {
|
|
120
|
+
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf-8"))
|
|
121
|
+
if (manifest.baseFramework === BASE_FRAMEWORK) {
|
|
122
|
+
return
|
|
123
|
+
}
|
|
124
|
+
manifest.baseFramework = BASE_FRAMEWORK
|
|
125
|
+
fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, "\t"))
|
|
126
|
+
console.log(`✓ Set baseFramework in app-manifest.json (${BASE_FRAMEWORK})`)
|
|
127
|
+
} catch (error) {
|
|
128
|
+
console.warn(
|
|
129
|
+
"⚠ Could not set baseFramework in app-manifest.json:",
|
|
130
|
+
error.message,
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
104
135
|
/**
|
|
105
136
|
* Installs npm dependencies
|
|
106
137
|
*/
|
|
@@ -244,6 +275,7 @@ module.exports = {
|
|
|
244
275
|
safeCopyFile,
|
|
245
276
|
createPackageJson,
|
|
246
277
|
updateAppManifest,
|
|
278
|
+
ensureBaseFramework,
|
|
247
279
|
installDependencies,
|
|
248
280
|
updateExistingProject,
|
|
249
281
|
isImageMagickInstalled,
|
package/package.json
CHANGED
|
@@ -47,7 +47,7 @@ function getApiConfig() {
|
|
|
47
47
|
const projectId = import.meta.env.VITE_API_PROJECT_ID || ""
|
|
48
48
|
const useHttps = import.meta.env.VITE_USE_HTTPS !== "false"
|
|
49
49
|
const nodePort = import.meta.env.VITE_NODE_PORT || "3060"
|
|
50
|
-
const mockPort = import.meta.env.VITE_SOCKET_IO_PORT || "
|
|
50
|
+
const mockPort = import.meta.env.VITE_SOCKET_IO_PORT || "3069"
|
|
51
51
|
|
|
52
52
|
// Check if we're in development mode (Vite dev server)
|
|
53
53
|
const isDev = import.meta.env.DEV
|
package/runtime/vite.config.js
CHANGED
|
@@ -120,6 +120,40 @@ function hasLocalFile(fileName) {
|
|
|
120
120
|
* concatenated, objects (resolve.alias, define, etc.) are merged key-by-key,
|
|
121
121
|
* primitives are overwritten.
|
|
122
122
|
*/
|
|
123
|
+
/**
|
|
124
|
+
* Try to load the `@tailwindcss/vite` plugin from the project's node_modules.
|
|
125
|
+
*
|
|
126
|
+
* Tailwind 4 is a DEV-ONLY base CSS framework here — declared in the project's
|
|
127
|
+
* devDependencies and imported via `@import "tailwindcss";` inside the
|
|
128
|
+
* theme-layouts. We deliberately do not run it during `vite build`:
|
|
129
|
+
*
|
|
130
|
+
* 1. The layouts aren't part of the production build (entry is
|
|
131
|
+
* `src/Plugin.vue`), so there's no `@import "tailwindcss"` reaching the
|
|
132
|
+
* build graph and the generated utilities would have nowhere to live.
|
|
133
|
+
* 2. The plugin scans the whole project (including `node_modules`) for
|
|
134
|
+
* candidate class names. `@gxp-dev/uikit` ships compiled Vue files
|
|
135
|
+
* containing arbitrary-value classes like
|
|
136
|
+
* `bg-[var(--keyboard_key_active_background_color,var(--primary))]`,
|
|
137
|
+
* which Tailwind 4 lowers to CSS with spaces in the var name — invalid
|
|
138
|
+
* CSS that breaks `lightningcss` minification at build time.
|
|
139
|
+
*
|
|
140
|
+
* In dev (`command === "serve"`) we load it; in build we skip and let the
|
|
141
|
+
* platform supply Tailwind at runtime (per `app-manifest.json.baseFramework`).
|
|
142
|
+
* Silently no-ops if the user has uninstalled Tailwind.
|
|
143
|
+
*/
|
|
144
|
+
async function loadTailwindPlugin(command) {
|
|
145
|
+
if (command !== "serve") {
|
|
146
|
+
return null
|
|
147
|
+
}
|
|
148
|
+
try {
|
|
149
|
+
const mod = await import("@tailwindcss/vite")
|
|
150
|
+
const plugin = mod.default ?? mod
|
|
151
|
+
return typeof plugin === "function" ? plugin() : null
|
|
152
|
+
} catch {
|
|
153
|
+
return null
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
123
157
|
async function loadExtensionConfig(ctx, runtimeConfig) {
|
|
124
158
|
const candidates = ["vite.extend.js", "vite.extend.mjs"]
|
|
125
159
|
for (const name of candidates) {
|
|
@@ -415,6 +449,13 @@ export default defineConfig(async (ctx) => {
|
|
|
415
449
|
// Determine if HTTPS is enabled
|
|
416
450
|
const useHttps = getHttpsConfig(env) !== undefined
|
|
417
451
|
|
|
452
|
+
// Load Tailwind 4 Vite plugin from the project's node_modules if present.
|
|
453
|
+
// Dev-only — production builds skip it (see loadTailwindPlugin docs).
|
|
454
|
+
const tailwindPlugin = await loadTailwindPlugin(ctx.command)
|
|
455
|
+
if (tailwindPlugin) {
|
|
456
|
+
console.log("🎨 Tailwind: @tailwindcss/vite plugin loaded (dev)")
|
|
457
|
+
}
|
|
458
|
+
|
|
418
459
|
// Get API proxy target for non-mock environments
|
|
419
460
|
const apiProxyTarget = getApiProxyTarget(env)
|
|
420
461
|
if (apiProxyTarget) {
|
|
@@ -448,6 +489,8 @@ export default defineConfig(async (ctx) => {
|
|
|
448
489
|
},
|
|
449
490
|
plugins: [
|
|
450
491
|
runtimeFilesPlugin,
|
|
492
|
+
// Tailwind 4 Vite plugin (no-op if @tailwindcss/vite isn't installed).
|
|
493
|
+
...((tailwindPlugin && [tailwindPlugin]) || []),
|
|
451
494
|
// Source tracker must run BEFORE vue() to transform templates before compilation
|
|
452
495
|
...(useSourceTracker ? [gxpSourceTrackerPlugin()] : []),
|
|
453
496
|
vue(),
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
"description": "GxToolkit Plugin",
|
|
5
5
|
"manifest_version": 3,
|
|
6
6
|
"asset_dir": "/src/public",
|
|
7
|
+
"baseFramework": "tailwindcss@^4.3.0",
|
|
7
8
|
"configurationFile": "configuration.json",
|
|
8
9
|
"appInstructionsFile": "app-instructions.md",
|
|
9
10
|
"defaultStylingFile": "default-styling.css",
|
package/template/env.example
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
<slot />
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
|
+
<!--
|
|
6
|
+
Tailwind base/utilities for development only. The layouts wrap the plugin in
|
|
7
|
+
the dev runtime but are NOT part of the production build (build entry is
|
|
8
|
+
src/Plugin.vue), so this CSS never ships in dist/. Remove this block if you
|
|
9
|
+
don't want Tailwind defaults applied while developing.
|
|
10
|
+
-->
|
|
11
|
+
<style>
|
|
12
|
+
@import "tailwindcss";
|
|
13
|
+
</style>
|
|
14
|
+
|
|
5
15
|
<style scoped></style>
|
|
6
16
|
|
|
7
17
|
<script setup>
|
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
<slot />
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
|
+
<!--
|
|
6
|
+
Tailwind base/utilities for development only. The layouts wrap the plugin in
|
|
7
|
+
the dev runtime but are NOT part of the production build (build entry is
|
|
8
|
+
src/Plugin.vue), so this CSS never ships in dist/. Remove this block if you
|
|
9
|
+
don't want Tailwind defaults applied while developing.
|
|
10
|
+
-->
|
|
11
|
+
<style>
|
|
12
|
+
@import "tailwindcss";
|
|
13
|
+
</style>
|
|
14
|
+
|
|
5
15
|
<style scoped></style>
|
|
6
16
|
|
|
7
17
|
<script setup>
|
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
<slot />
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
|
+
<!--
|
|
6
|
+
Tailwind base/utilities for development only. The layouts wrap the plugin in
|
|
7
|
+
the dev runtime but are NOT part of the production build (build entry is
|
|
8
|
+
src/Plugin.vue), so this CSS never ships in dist/. Remove this block if you
|
|
9
|
+
don't want Tailwind defaults applied while developing.
|
|
10
|
+
-->
|
|
11
|
+
<style>
|
|
12
|
+
@import "tailwindcss";
|
|
13
|
+
</style>
|
|
14
|
+
|
|
5
15
|
<style scoped></style>
|
|
6
16
|
|
|
7
17
|
<script setup>
|