@uniweb/build 0.1.12 → 0.1.13
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/package.json +1 -1
- package/src/site/config.js +10 -88
package/package.json
CHANGED
package/src/site/config.js
CHANGED
|
@@ -24,10 +24,6 @@ import { existsSync, readFileSync } from 'node:fs'
|
|
|
24
24
|
import { resolve, dirname } from 'node:path'
|
|
25
25
|
import yaml from 'js-yaml'
|
|
26
26
|
|
|
27
|
-
// Virtual module ID for the site entry
|
|
28
|
-
const VIRTUAL_ENTRY_ID = 'virtual:uniweb-site-entry'
|
|
29
|
-
const RESOLVED_VIRTUAL_ENTRY_ID = '\0' + VIRTUAL_ENTRY_ID
|
|
30
|
-
|
|
31
27
|
/**
|
|
32
28
|
* Detect foundation type from the foundation config value
|
|
33
29
|
*
|
|
@@ -90,61 +86,6 @@ function detectFoundationType(foundation, siteRoot) {
|
|
|
90
86
|
}
|
|
91
87
|
}
|
|
92
88
|
|
|
93
|
-
/**
|
|
94
|
-
* Generate the virtual entry module code based on foundation config
|
|
95
|
-
*
|
|
96
|
-
* @param {{ type: string, url?: string, cssUrl?: string }} foundationInfo
|
|
97
|
-
* @param {boolean} isRuntimeMode
|
|
98
|
-
* @returns {string}
|
|
99
|
-
*/
|
|
100
|
-
function generateEntryCode(foundationInfo, isRuntimeMode) {
|
|
101
|
-
if (isRuntimeMode || foundationInfo.type === 'url') {
|
|
102
|
-
// Runtime loading - foundation loaded dynamically
|
|
103
|
-
const url = foundationInfo.url || '/foundation/foundation.js'
|
|
104
|
-
const cssUrl = foundationInfo.cssUrl || '/foundation/assets/style.css'
|
|
105
|
-
|
|
106
|
-
return `
|
|
107
|
-
import { initRuntime } from '@uniweb/runtime'
|
|
108
|
-
|
|
109
|
-
initRuntime({
|
|
110
|
-
url: '${url}',
|
|
111
|
-
cssUrl: '${cssUrl}'
|
|
112
|
-
})
|
|
113
|
-
`
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Bundled mode - foundation imported at build time
|
|
117
|
-
return `
|
|
118
|
-
import { initRuntime } from '@uniweb/runtime'
|
|
119
|
-
import foundation from '#foundation'
|
|
120
|
-
import '#foundation/styles'
|
|
121
|
-
|
|
122
|
-
initRuntime(foundation)
|
|
123
|
-
`
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Create the virtual entry plugin
|
|
128
|
-
*/
|
|
129
|
-
function virtualEntryPlugin(foundationInfo, isRuntimeMode) {
|
|
130
|
-
const entryCode = generateEntryCode(foundationInfo, isRuntimeMode)
|
|
131
|
-
|
|
132
|
-
return {
|
|
133
|
-
name: 'uniweb:virtual-entry',
|
|
134
|
-
enforce: 'pre',
|
|
135
|
-
resolveId(id) {
|
|
136
|
-
if (id === VIRTUAL_ENTRY_ID) {
|
|
137
|
-
return RESOLVED_VIRTUAL_ENTRY_ID
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
load(id) {
|
|
141
|
-
if (id === RESOLVED_VIRTUAL_ENTRY_ID) {
|
|
142
|
-
return entryCode
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
89
|
/**
|
|
149
90
|
* Read and parse site.yml configuration
|
|
150
91
|
*
|
|
@@ -221,9 +162,6 @@ export async function defineSiteConfig(options = {}) {
|
|
|
221
162
|
|
|
222
163
|
// Build the plugins array
|
|
223
164
|
const plugins = [
|
|
224
|
-
// Virtual entry module
|
|
225
|
-
virtualEntryPlugin(foundationInfo, isRuntimeMode),
|
|
226
|
-
|
|
227
165
|
// Standard plugins
|
|
228
166
|
tailwindcss(),
|
|
229
167
|
react(),
|
|
@@ -260,20 +198,20 @@ export async function defineSiteConfig(options = {}) {
|
|
|
260
198
|
alias['#foundation'] = foundationInfo.name
|
|
261
199
|
}
|
|
262
200
|
|
|
263
|
-
//
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
},
|
|
269
|
-
...resolveOverrides
|
|
201
|
+
// Build foundation config for runtime
|
|
202
|
+
const foundationConfig = {
|
|
203
|
+
mode: isRuntimeMode ? 'runtime' : 'bundled',
|
|
204
|
+
url: foundationInfo.url || '/foundation/foundation.js',
|
|
205
|
+
cssUrl: foundationInfo.cssUrl || '/foundation/assets/style.css'
|
|
270
206
|
}
|
|
271
|
-
delete resolveConfig.alias // We'll add it back properly
|
|
272
|
-
resolveConfig.alias = { ...alias, ...resolveOverrides.alias }
|
|
273
207
|
|
|
274
208
|
return {
|
|
275
209
|
plugins,
|
|
276
210
|
|
|
211
|
+
define: {
|
|
212
|
+
__FOUNDATION_CONFIG__: JSON.stringify(foundationConfig)
|
|
213
|
+
},
|
|
214
|
+
|
|
277
215
|
resolve: {
|
|
278
216
|
alias: {
|
|
279
217
|
...alias,
|
|
@@ -292,23 +230,7 @@ export async function defineSiteConfig(options = {}) {
|
|
|
292
230
|
},
|
|
293
231
|
|
|
294
232
|
optimizeDeps: {
|
|
295
|
-
include: ['react', 'react-dom', 'react-dom/client', 'react-router-dom']
|
|
296
|
-
exclude: ['virtual:uniweb-site-entry'],
|
|
297
|
-
esbuildOptions: {
|
|
298
|
-
plugins: [
|
|
299
|
-
{
|
|
300
|
-
name: 'virtual-entry-resolver',
|
|
301
|
-
setup(build) {
|
|
302
|
-
// Tell esbuild that virtual:uniweb-site-entry is external
|
|
303
|
-
// This prevents the "could not be resolved" error during dep scanning
|
|
304
|
-
build.onResolve({ filter: /^virtual:uniweb-site-entry$/ }, () => ({
|
|
305
|
-
path: 'virtual:uniweb-site-entry',
|
|
306
|
-
external: true
|
|
307
|
-
}))
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
]
|
|
311
|
-
}
|
|
233
|
+
include: ['react', 'react-dom', 'react-dom/client', 'react-router-dom']
|
|
312
234
|
},
|
|
313
235
|
|
|
314
236
|
...restOptions
|