vite-plugin-milpa 0.1.0 → 0.1.1
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/README.md +3 -1
- package/index.js +29 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,7 +33,9 @@ export default defineConfig({
|
|
|
33
33
|
|
|
34
34
|
1. **`base` + `build.manifest` + entry** — lo que el helper `vite()` de milpa necesita para
|
|
35
35
|
emitir `<link>`/`<script>` hasheados en prod. La base se deriva de la carpeta:
|
|
36
|
-
`surcos/<app>` → `/vite/<app>/`.
|
|
36
|
+
`surcos/<app>` → `/vite/<app>/`. Los chunks salen con NOMBRE legible derivado de la ruta
|
|
37
|
+
del módulo (`modules/tienda/pages/productos/[id].jsx` → `tienda-productos-id-<hash>.js`)
|
|
38
|
+
— sin esto, el file-routing produce puros `index-<hash>.js` indistinguibles.
|
|
37
39
|
2. **Build a `public/<app>` del proyecto** (estilo `mix.js` → `public/` de Laravel): milpa
|
|
38
40
|
monta `public/` completo y un solo mount sirve a todas las apps.
|
|
39
41
|
3. **Hot-file (modelo Laravel)** — `npm run dev` escribe `./hot` con la URL real del dev
|
package/index.js
CHANGED
|
@@ -61,6 +61,26 @@ function resolveBase(options, root) {
|
|
|
61
61
|
return url.endsWith('/') ? url : `${url}/`;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
// Nombre LEGIBLE para cada chunk, derivado de la ruta del módulo que lo origina
|
|
65
|
+
// (su facade): con file-routing casi todas las páginas se llaman index.jsx y
|
|
66
|
+
// Rollup nombra por basename → un desfile de "index-<hash>.js" indistinguibles.
|
|
67
|
+
// pages/acerca.jsx → acerca · modules/tienda/pages/productos/[id].jsx →
|
|
68
|
+
// tienda-productos-id · _layout → tienda-layout. Los segmentos ruido
|
|
69
|
+
// (src/modules/pages) se omiten; chunks sin facade (compartidos/vendor) caen
|
|
70
|
+
// al default [name] de Rollup.
|
|
71
|
+
function chunkName(facadeModuleId) {
|
|
72
|
+
if (!facadeModuleId) return null;
|
|
73
|
+
const match = facadeModuleId.split('?')[0].match(/\/src\/(.+)\.(jsx|tsx|js|ts)$/);
|
|
74
|
+
if (!match) return null;
|
|
75
|
+
const name = match[1]
|
|
76
|
+
.split('/')
|
|
77
|
+
.filter((segment) => segment !== 'modules' && segment !== 'pages')
|
|
78
|
+
.map((segment) => segment.replace(/^\[(.+)\]$/, '$1').replace(/^_/, ''))
|
|
79
|
+
.filter(Boolean)
|
|
80
|
+
.join('-');
|
|
81
|
+
return name || null;
|
|
82
|
+
}
|
|
83
|
+
|
|
64
84
|
function configPlugin(options) {
|
|
65
85
|
return {
|
|
66
86
|
name: 'milpa:config',
|
|
@@ -72,7 +92,15 @@ function configPlugin(options) {
|
|
|
72
92
|
base: command === 'build' ? resolveBase(options, config.root) : '/',
|
|
73
93
|
build: {
|
|
74
94
|
manifest: true,
|
|
75
|
-
rollupOptions: {
|
|
95
|
+
rollupOptions: {
|
|
96
|
+
input: options.entry,
|
|
97
|
+
output: {
|
|
98
|
+
chunkFileNames(chunkInfo) {
|
|
99
|
+
const name = chunkName(chunkInfo.facadeModuleId);
|
|
100
|
+
return name ? `assets/${name}-[hash].js` : 'assets/[name]-[hash].js';
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
76
104
|
// El build cae en public/<app> del PROYECTO (como mix.js a
|
|
77
105
|
// public/ en Laravel). emptyOutDir explícito: Vite no limpia
|
|
78
106
|
// solo los outDir fuera del root del frontend.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-milpa",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "El toolkit frontend del framework milpa (FastAPI + Jinja), estilo laravel-vite-plugin: hot-file para HMR, manifest para el helper vite() de Jinja, multi-app (surcos/), PWA opcional con Serwist, ASSET_URL para deploy bajo sub-ruta/CDN — y file-based routing para react-router 7 vía `vite-plugin-milpa/router`.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|