@ryziz/cli 0.0.45 → 0.0.46
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
|
@@ -56,7 +56,7 @@ export default (isDev) => task('Building', {
|
|
|
56
56
|
external: ['firebase-admin', 'firebase-functions', 'express'],
|
|
57
57
|
plugins: [
|
|
58
58
|
{ name: 'log', setup: (b) => b.onEnd(() => { c.onFunctionsBuilt?.(); }) },
|
|
59
|
-
{ 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
|
|
59
|
+
{ 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 handler${i} = require('./src/${r.file}');`).join('\n'); const entries = routes.map((r, i) => `{path:'${r.path}',handler:handler${i}.default || handler${i},functionName:'${r.functionName}'}`).join(','); return { contents: `${requires}\nmodule.exports = [${entries}];`, loader: 'js', resolveDir: c.root, watchDirs: [c.src] }; }); } },
|
|
60
60
|
{ name: 'fb', setup: (b) => b.onEnd(() => { const routes = scanApiRoutes(); const cfg = JSON.parse(readFileSync(join(c.functionsPkg, 'firebase.json'))); writeFileSync(join(c.dist, 'firebase.json'), JSON.stringify({ ...cfg, hosting: { ...cfg.hosting, rewrites: [...routes.map((r) => ({ source: r.path, function: r.functionName })), { source: '**', destination: '/index.html' }] } }, null, 2)); }) },
|
|
61
61
|
],
|
|
62
62
|
});
|