-
-
Save jgcmarins/4ba4a0c207972e05603a647d12effae9 to your computer and use it in GitHub Desktop.
Webpack configuration for Google Cloud Functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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