-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.cjs
41 lines (39 loc) · 1.12 KB
/
webpack.config.cjs
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
const path = require("path");
const AwsSamPlugin = require("aws-sam-webpack-plugin");
const getEnvironment = (env) => {
if (env.prod) {
return 'prod';
}
if (env.dev) {
return 'dev';
}
throw new Error('No valid Webpack environment set');
};
module.exports = (env) => {
const environment = getEnvironment(env);
const awsSamPlugin = new AwsSamPlugin({
projects: {
[environment]: `./template.${environment}.yaml`,
},
outFile: "index"
});
return {
entry: () => awsSamPlugin.entry(),
output: {
filename: (chunkData) => awsSamPlugin.filename(chunkData),
libraryTarget: "commonjs2",
path: path.resolve("."),
},
devtool: "source-map",
resolve: {
extensions: [".ts", ".js"],
},
target: "node",
externals: process.env.NODE_ENV === "development" ? [] : ["aws-sdk"],
mode: process.env.NODE_ENV || "production",
module: {
rules: [{ test: /\.tsx?$/, loader: "ts-loader" }],
},
plugins: [awsSamPlugin],
};
};