Skip to content

Instantly share code, notes, and snippets.

@jkinkead
Created October 18, 2018 23:56
Show Gist options
  • Save jkinkead/0dcfd12a1bbbb20b28b2c6e996089169 to your computer and use it in GitHub Desktop.
Save jkinkead/0dcfd12a1bbbb20b28b2c6e996089169 to your computer and use it in GitHub Desktop.
Webpack configuration for Google Cloud Functions
const webpack = require('webpack')
const path = require('path')
const nodeExternals = require('webpack-node-externals')
const StartServerPlugin = require('start-server-webpack-plugin')
module.exports = {
entry: [
'webpack/hot/poll?1000',
'./local/server'
],
watch: true,
mode: 'development',
target: 'node',
externals: [nodeExternals({
whitelist: ['webpack/hot/poll?1000']
})],
module: {
rules: [{
test: /\.js?$/,
loader: 'babel-loader',
options: {
presets: [["@babel/preset-env", {"modules": false}]]
},
exclude: /node_modules/
}
]
},
plugins: [
new StartServerPlugin('server.js'),
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.DefinePlugin({
"process.env": {
"BUILD_TARGET": JSON.stringify('server')
}
})
],
output: {
path: path.join(__dirname, '.build'),
filename: 'server.js'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment