Skip to content

Instantly share code, notes, and snippets.

@kilgarenone
Created September 13, 2018 07:41
Show Gist options
  • Save kilgarenone/881bcd9cc557a00eee6cbb1de633b2b5 to your computer and use it in GitHub Desktop.
Save kilgarenone/881bcd9cc557a00eee6cbb1de633b2b5 to your computer and use it in GitHub Desktop.
webpack babel in serverless
const slsw = require('serverless-webpack');
const nodeExternals = require('webpack-node-externals');
module.exports = {
entry: slsw.lib.entries,
target: 'node',
// Generate sourcemaps for proper error messages
devtool: 'source-map',
// Since 'aws-sdk' is not compatible with webpack,
// we exclude all node dependencies
externals: [nodeExternals()],
mode: slsw.lib.webpack.isLocal ? 'development' : 'production',
optimization: {
// We no not want to minimize our code.
minimize: false,
},
performance: {
// Turn off size warnings for entry points
hints: false,
},
// Run babel on all .js files and skip those in node_modules
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
include: __dirname,
exclude: /node_modules/,
},
],
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment