-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
67 lines (60 loc) · 2.31 KB
/
webpack.config.js
File metadata and controls
67 lines (60 loc) · 2.31 KB
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
const path = require('path');
const slsw = require('serverless-webpack');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const nodeExternals = require('webpack-node-externals');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
module.exports = {
// `mode` will be set to `production` and comes with included optimizations
// when building to be run on AWS or similar.
// https://webpack.js.org/configuration/mode/
mode: slsw.lib.webpack.isLocal ? 'development' : 'production',
// to determine what source maps to use per dev or prod
// https://webpack.js.org/configuration/devtool/
devtool: slsw.lib.webpack.isLocal ? 'source-map' : 'cheap-source-map',
// the provided argument will be an object referencing functions as defined
// in your `serverless.yml` .
// https://webpack.js.org/concepts/entry-points/
entry: slsw.lib.entries,
target: 'node',
resolve: {
extensions: ['.js', '.ts'],
plugins: [new TsconfigPathsPlugin()]
},
// Where the bundled files will be output. Not strictly necessary with
// Serverless Webpack.
// https://webpack.js.org/configuration/output/
output: {
libraryTarget: 'commonjs2',
path: path.join(__dirname, '.webpack'),
filename: '[name].js',
},
externals: [nodeExternals()],
module: {
// Instruct Webpack to use the `ts-loader` for any TypeScript files, else it
// won't know what to do with them.
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
loader: 'ts-loader',
exclude: [
[
path.resolve(__dirname, '.webpack'),
path.resolve(__dirname, '.serverless'),
],
],
// And here we have options for ts-loader
// https://www.npmjs.com/package/ts-loader#options
options: {
// Disable type checking, this will lead to improved build times
transpileOnly: true,
// Enable file caching, can be quite useful when running offline
experimentalFileCaching: true,
},
},
]
},
// We still want type checking, just without the burden on build performance,
// so we use a plugin to take care of it on another thread.
plugins: [new ForkTsCheckerWebpackPlugin()]
};