-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
43 lines (42 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
const nodeExternals = require('webpack-node-externals');
const CopyPlugin = require('copy-webpack-plugin');
const webpack = require('webpack');
const fs = require('fs');
const path = require('path');
const appConfig = JSON.parse(fs.readFileSync('config/appconfig.json', 'UTF-8'));
module.exports = {
mode: 'production',
plugins: [
new webpack.EnvironmentPlugin({
NODE_ENV: process.env.NODE_ENV ? process.env.NODE_ENV : 'dev', // use 'dev' unless process.env.NODE_ENV is defined
DEBUG: false,
}),
new CopyPlugin({
patterns: [
{ from: appConfig.jsonFile, to: '../db.json' },
{ from: './config/appconfig.json', to: './config/appconfig.json' },
],
}),
],
entry: { './src/handler': './src/handler.ts' },
resolve: {
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],
},
output: {
libraryTarget: 'commonjs',
path: path.join(__dirname, 'dist'),
filename: 'handler.js',
},
target: 'node',
externals: [
nodeExternals({
allowlist: ['swagger-ui-express', 'json-server'],
}),
],
module: {
rules: [
// all files with a `.ts` or `.tsx` extension will be handled by `ts-loader`
{ test: /\.tsx?$/, loader: 'ts-loader' },
],
},
};