-
Notifications
You must be signed in to change notification settings - Fork 29
/
webpack.cli.ts
64 lines (61 loc) · 1.54 KB
/
webpack.cli.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
53
54
55
56
57
58
59
60
61
62
63
64
import webpack, { type Configuration } from 'webpack';
import NodeExternals from 'webpack-node-externals';
import CopyPlugin from 'copy-webpack-plugin';
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
import { resolve } from 'path';
const MODE = process.env.BUILD_MODE === 'production' ? 'production' : 'development';
const config: Configuration = {
context: process.cwd(),
mode: MODE,
entry: './src/cli.ts',
output: {
filename: 'cli.js',
path: resolve(__dirname, 'dist'),
},
target: 'node',
stats: {
preset: 'minimal',
warnings: false,
},
module: {
rules: [
{
test: /\.(jsx?|tsx?)$/,
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true,
presets: ['@babel/preset-typescript'],
assumptions: {
setPublicClassFields: false,
},
},
},
exclude: [/node_modules/],
},
],
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx', '.d.ts'],
},
plugins: [
new ForkTsCheckerWebpackPlugin(),
new webpack.BannerPlugin({ banner: '#!/usr/bin/env node', raw: true }),
new CopyPlugin({
patterns: [
{ from: 'src/banner.txt', to: 'banner.txt' },
{
from: 'src/template',
to: 'template',
// Terser skip this file for minimization
info: { minimized: true },
},
],
}),
],
externalsPresets: { node: true },
externals: [
NodeExternals(),
],
};
export default config;