-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.config.js
44 lines (34 loc) · 1.31 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const path = require('path');
const AwsSamPlugin = require('aws-sam-webpack-plugin');
const awsSamPlugin = new AwsSamPlugin({ vscodeDebug: false });
module.exports = {
// Loads the entry object from the AWS::Serverless::Function resources in your
// SAM config. Setting this to a function will
entry: () => awsSamPlugin.entry(),
// Write the output to the .aws-sam/build folder
output: {
filename: (chunkData) => awsSamPlugin.filename(chunkData),
libraryTarget: 'commonjs2',
path: path.resolve('.')
},
// Create source maps
devtool: 'source-map',
// Resolve .ts and .js extensions
resolve: {
extensions: ['.ts', '.js']
},
// Target node
target: 'node',
// AWS recommends always including the aws-sdk in your Lambda package but excluding can significantly reduce
// the size of your deployment package. If you want to always include it then comment out this line. It has
// been included conditionally because the node10.x docker image used by SAM local doesn't include it.
externals: process.env.NODE_ENV === 'development' ? [] : ['aws-sdk'],
// Set the webpack mode
mode: process.env.NODE_ENV || 'production',
// Add the TypeScript loader
module: {
rules: [{ test: /\.tsx?$/, loader: 'ts-loader' }]
},
// Add the AWS SAM Webpack plugin
plugins: [awsSamPlugin]
};