-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.ts
54 lines (49 loc) · 1.18 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
53
54
import * as path from 'path';
import * as webpack from 'webpack';
const generalConfig: webpack.Configuration = {
mode: process.env.NODE_ENV == 'production' ? 'production' : 'development',
entry: './src/index.ts',
module: {
rules: [
{
test: /\.ts$/i,
loader: 'ts-loader',
exclude: ['/node_modules/'],
},
],
},
resolve: {
extensions: ['.ts'],
},
};
const nodeEsmConfig: webpack.Configuration = {
...generalConfig,
target: 'node',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'node-esm.js',
library: { type: 'commonjs-static' },
},
};
const nodeRequireConfig: webpack.Configuration = {
...generalConfig,
target: 'node',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'node-require.js',
library: { name: 'mdTable', type: 'umd' },
},
};
const browserConfig: webpack.Configuration = {
...generalConfig,
target: 'web',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'browser.js',
libraryTarget: 'umd',
globalObject: 'this',
umdNamedDefine: true,
library: 'mdTable',
},
};
export default [nodeEsmConfig, browserConfig, nodeRequireConfig];