Skip to content

Instantly share code, notes, and snippets.

@thekarel
Created February 14, 2020 07:04
Show Gist options
  • Save thekarel/a12416743e56a45976ba628853cb64a4 to your computer and use it in GitHub Desktop.
Save thekarel/a12416743e56a45976ba628853cb64a4 to your computer and use it in GitHub Desktop.
Firebase Functions in Monorepo

The firebase.json should be in the root of the workspace and it only shows the relevant bits.

Put the webpack config into modules/firebase/

Before deploying the functions, build the function bundle with webpack (it will end up in dist/).

{
"functions": {
"source": "modules/firebase/dist"
},
}
const path = require('path')
module.exports = {
target: 'node',
mode: 'production',
entry: path.resolve(__dirname, 'src', 'index.ts'),
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.mjs', '.js', '.json'],
},
output: {
filename: 'index.js',
path: path.resolve(__dirname, './dist'),
libraryTarget: 'commonjs',
},
externals: {
'firebase-admin': 'firebase-admin',
'firebase-functions': 'firebase-functions',
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment