I am new to webpack and serverless, so please forgive me if this seems trivial. I copied these codes from npm serverless-webpack.
I tried to use serverless webpack --out dist, but my command line didn't recognise webpack. If I tried to serverless deploy <opts> <opt>, then it compiled and bundled into a .serverless but missing the essential JS files.
webpack.config.js
var path = require('path');
var slsw = require('serverless-webpack');
var nodeExternals = require('webpack-node-externals');
module.exports = {
context: path.resolve(__dirname, './src'),
entry: slsw.lib.entries,
target: 'node',
externals: [nodeExternals()],
output: {
libraryTarget: 'commonjs',
path: path.resolve(__dirname, '.webpack'),
filename: '[name].js',
},
module: {
rules: [
{
test: /\.jsx$/,
loader: ["babel-loader"],
include: __dirname,
exclude: /node_modules/
}
]
}
};
Serverless.yml
service: hello-world
frameworkVersion: '>=1.2.0 <2.0.0'
provider:
name: aws
runtime: nodejs8.10
deploymentBucket:
name: test-bucket
plugin:
- serverless-webpack
- serverless-prune-plugin
custom:
prune:
automatic: true
number: 3
webpack: webpack.config.js
webpackIncludeModules:
packagePath: ./src/package.json
forceInclude:
- express
- body-parser
functions:
getHelloWorld:
handler: functions/test.hello
events:
- http:
path: test/hello
method: get
webpack: 4.22.0 (global)
serverless-webpack: 5.3.0 (global)

serverless.ymlis misconfigured and/or out-of-sync with respect to yourwebpack.config.js. Can you post that as well?serverless.yml