-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
60 lines (50 loc) · 1.22 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
require('dotenv').config();
const path = require('path');
const webpack = require('webpack');
const nodeExternals = require('webpack-node-externals');
const isDev = process.env.NODE_ENV === 'development';
const resolve = path.resolve.bind(path, __dirname);
const entry = {
'origin-response': './src/origin-response.ts',
'viewer-request': './src/viewer-request.ts',
};
const output = {
path: resolve('dist'),
filename: '[name]/index.js',
library: 'cloudfront-lambda-image-resizing',
libraryTarget: 'umd',
};
const plugins = [
new webpack.DefinePlugin({
BUCKET: '"' + process.env.BUCKET + '"',
INFO_LOG: process.env.INFO_LOG === 'true',
}),
];
const jsRule = {
test: /\.j(s|sx)$/,
exclude: /node_modules/,
loader: 'babel-loader',
};
const tsRule = {
test: /\.t(s|sx)$/,
exclude: /node_modules/,
loader: 'ts-loader',
};
const rules = [jsRule, tsRule];
const resolve_obj = {
alias: {},
extensions: ['.js', '.ts'],
};
const config = {
mode: isDev ? 'development' : 'production',
target: 'node',
name: 'cloudfront-lambda-image-resizing',
entry,
output,
// devtool: 'eval',
module: { rules },
plugins,
resolve: resolve_obj,
externals: [nodeExternals()],
};
module.exports = config;