This repository has been archived by the owner on Jul 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
89 lines (83 loc) · 1.93 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
"use strict";
const webpack = require("webpack");
const slsw = require("serverless-webpack");
const HardSourceWebpackPlugin = require("hard-source-webpack-plugin");
function babelLoader() {
const plugins = [
"@babel/plugin-transform-runtime",
"@babel/plugin-proposal-class-properties",
"babel-plugin-source-map-support",
];
return {
loader: "babel-loader",
options: {
cacheDirectory: true,
cacheCompression: false,
plugins: plugins.map(plugin => require.resolve(plugin)),
presets: [
[
require.resolve("@babel/preset-env"),
{
targets: {
node: Number.parseInt(
slsw.lib.serverless.service.provider.runtime.replace(
"nodejs",
"",
),
10,
),
},
},
],
],
},
};
}
function plugins() {
const plugins = [
new HardSourceWebpackPlugin({
info: {
mode: "none",
level: "error",
},
}),
new webpack.DefinePlugin(slsw.lib.serverless.service.provider.environment),
];
return plugins;
}
module.exports = {
entry: slsw.lib.entries,
target: "node",
context: __dirname,
stats: "errors-only",
devtool: "source-map",
// Exclude "aws-sdk" since it's a built-in package
externals: ["aws-sdk", "oax"],
mode: "production",
performance: {
// Turn off size warnings for entry points
hints: false,
},
resolve: {
// Performance
// symlinks: false,
// First start by looking for modules in the plugin's node_modules
// before looking inside the project's node_modules.
modules: ["node_modules"],
},
// Add loaders
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: [babelLoader()],
},
],
},
// PERFORMANCE ONLY FOR DEVELOPMENT
optimization: {
minimize: false,
},
plugins: plugins(),
};