-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.ts
52 lines (49 loc) · 1.32 KB
/
webpack.config.ts
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
import webpack, { WebpackPluginInstance } from 'webpack'
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'
import nodeExternals from 'webpack-node-externals'
import TerserPlugin from 'terser-webpack-plugin'
import path from 'path'
const isDev = process.env.NODE_ENV !== 'production'
const getPlugins = (): WebpackPluginInstance[] => {
const plugins = [new webpack.ProgressPlugin()]
if (isDev) {
plugins.push(new ForkTsCheckerWebpackPlugin())
}
return plugins
}
const config: webpack.Configuration = {
name: 'server',
context: path.resolve(process.cwd()),
mode: isDev ? 'development' : 'production',
devtool: isDev ? 'inline-source-map' : 'source-map',
target: 'node',
entry: {
webapp: './webapp/server.ts',
consumer: './consumer/plan.consumer.ts',
graphql: './graphql/graphql-server.ts'
},
output: {
clean: true,
publicPath: 'dist/',
path: path.resolve(process.cwd(), 'dist'),
filename: '[name].js'
},
optimization: {
minimizer: [new TerserPlugin({ terserOptions: { compress: { drop_console: true } } })]
},
resolve: {
extensions: ['.ts']
},
module: {
rules: [
{
test: /\.ts?$/,
use: 'ts-loader',
exclude: /node_modules/
}
]
},
externals: [nodeExternals()],
plugins: getPlugins()
}
export default config