Skip to content

Instantly share code, notes, and snippets.

@apotox
Last active May 24, 2019 15:47
Show Gist options
  • Save apotox/3c1261e682dfeb7d0cbb0c17a02f0d80 to your computer and use it in GitHub Desktop.
Save apotox/3c1261e682dfeb7d0cbb0c17a02f0d80 to your computer and use it in GitHub Desktop.
webpack.config.js firebase-sdk-with-netlify-functions
//webpack.config.js
require('dotenv').config()
const path = require('path');
const pkg = require('./package')
const GenerateJsonPlugin = require('generate-json-webpack-plugin')
const externals = [
'firebase-admin',
'lodash'
]
const genPackage = () => ({
name: 'functions',
private: true,
main: 'hello.js',
author:"@saphidev",
license: 'MIT',
dependencies: externals.reduce(
(acc, name) =>
Object.assign({}, acc, {
[name]:
pkg.dependencies[name] ||
pkg.devDependencies[name]
}),
{}
)
})
module.exports = {
target: 'node',
resolve: {
mainFields: ['module', 'main']
},
externals: externals.reduce(
(acc, name) => Object.assign({}, acc, { [name]: true }),
{}
),
plugins: [new GenerateJsonPlugin('package.json', genPackage())]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment