@ryziz/cli 0.0.51 → 0.0.52
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/build.js +1 -1
package/package.json
CHANGED
package/src/build.js
CHANGED
|
@@ -73,7 +73,7 @@ export default (isDev) => task('Building', {
|
|
|
73
73
|
plugins: [
|
|
74
74
|
{ name: 'log', setup: (b) => b.onEnd(() => { c.onFunctionsBuilt?.(); }) },
|
|
75
75
|
{ name: 'var', setup: (b) => { b.onResolve({ filter: /^virtual:api-routes$/ }, (a) => ({ path: a.path, namespace: 'var' })); b.onLoad({ filter: /.*/, namespace: 'var' }, () => { const routes = scanApiRoutes(); const requires = routes.map((r, i) => `const module${i} = require('./src/${r.file}');`).join('\n'); const entries = routes.map((r, i) => `{path:'${r.path}',handler:module${i}.default || module${i},config:module${i}.config,functionName:'${r.functionName}'}`).join(','); return { contents: `${requires}\nmodule.exports = [${entries}];`, loader: 'js', resolveDir: c.root, watchDirs: [c.src] }; }); } },
|
|
76
|
-
{ name: 'fb', setup: (b) => b.onEnd(() => { const routes = scanApiRoutes(); const cfg = JSON.parse(readFileSync(join(c.functionsPkg, 'firebase.json'))); const
|
|
76
|
+
{ name: 'fb', setup: (b) => b.onEnd(() => { const routes = scanApiRoutes(); const cfg = JSON.parse(readFileSync(join(c.functionsPkg, 'firebase.json'))); const standalone = routes.filter((r) => r.hasConfig); const hasMerged = routes.some((r) => !r.hasConfig); const rewrites = [...standalone.map((r) => ({ source: r.path.replace(/:[^/]+/g, '*'), function: r.functionName })), ...(hasMerged ? [{ source: '/api/**', function: 'api' }] : []), { source: '**', destination: '/index.html' }]; writeFileSync(join(c.dist, 'firebase.json'), JSON.stringify({ ...cfg, hosting: { ...cfg.hosting, rewrites } }, null, 2)); }) },
|
|
77
77
|
],
|
|
78
78
|
});
|
|
79
79
|
|