-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.ts
43 lines (40 loc) · 1.24 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
import ESLintPlugin from 'eslint-webpack-plugin';
import path from 'path';
import type webpack from 'webpack';
import { dependencies, name } from './package.json';
import { compilerOptions } from './tsconfig.json';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const DtsBundleWebpack = require('dts-bundle-webpack');
const createAliases = () => {
const baseUrl = path.resolve(__dirname, compilerOptions.baseUrl || '.');
return Object.fromEntries(
Object.entries(compilerOptions.paths || {}).map(([key, [value]]) => [
key.replace('*', ''),
path.resolve(baseUrl, value.replace('*', '')),
])
);
};
export default <webpack.Configuration>{
cache: true,
devtool: 'source-map',
externals: Object.keys(dependencies || {}),
mode: 'production',
module: { rules: [{ test: /\.ts$/, use: 'ts-loader' }] },
output: {
filename: 'index.js',
path: `${__dirname}/dist`,
library: name,
libraryTarget: 'umd',
},
plugins: [
new DtsBundleWebpack({
indent: ' ',
main: `${__dirname}/dist/src/index.d.ts`,
name,
out: `${__dirname}/dist/index.d.ts`,
}),
new ESLintPlugin({}),
],
resolve: { alias: createAliases(), extensions: ['.js', '.json', '.ts'] },
target: 'node',
};