forked from samuelmeuli/mini-diary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.base.ts
40 lines (38 loc) · 963 Bytes
/
webpack.base.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
import path from "path";
import LicenseCheckerWebpackPlugin from "license-checker-webpack-plugin";
import { CliConfigOptions, Configuration } from "webpack";
export default (
_: string | Record<string, boolean | number | string>,
args: CliConfigOptions,
): Configuration => {
const configName = args.config?.split(".")[2];
return {
output: {
path: path.resolve(__dirname, "bundle"),
},
devtool: args.mode === "production" ? false : "source-map",
resolve: {
extensions: [".js", ".jsx", ".json", ".ts", ".tsx"],
},
module: {
rules: [
{
test: [/\.jsx?$/, /\.tsx?$/],
use: "babel-loader",
exclude: /node_modules/,
},
],
},
// @ts-ignore
plugins: [
...(args.mode === "production"
? [
new LicenseCheckerWebpackPlugin({
allow: "(Apache-2.0 OR BSD-2-Clause OR BSD-3-Clause OR ISC OR MIT OR Zlib)",
outputFilename: `licenses-${configName}.txt`,
}),
]
: []),
],
};
};