forked from peradnya/balinese-date-js-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
60 lines (56 loc) · 1.78 KB
/
webpack.config.js
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
const path = require("path");
const webpack = require("webpack");
const libraryName = "BalineseDate";
const libraryFileName = "balinese-date-js-lib";
const license = "BalineseDate is licensed under the " +
"[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)." +
"\n"+
"BalineseDate (UMD) is bundled with **date-fns** that licensed under the " +
"[MIT license](http://kossnocorp.mit-license.org).";
const config = {
entry: path.join(__dirname, "src", libraryName + ".ts"),
output: {
path: path.join(__dirname, "umd"),
library: libraryName,
libraryTarget: "umd2",
umdNamedDefine: true,
globalObject: "this"
},
devtool: "source-map",
module: {
rules: [
{
test: /\.ts$/,
enforce: "pre",
use: [{
loader: "tslint-loader",
options: {
emitErrors: true,
failOnHint: true
}
}],
exclude: [/node_modules/]
},
{
test: /\.ts$/,
use: [{ loader: "ts-loader" }],
exclude: [/node_modules/]
}
]
},
resolve: {
modules: [path.resolve("./src"), path.resolve("./node_modules")],
extensions: [".js", ".ts"]
},
plugins: [
new webpack.BannerPlugin(license),
]
}
module.exports = (env, argv) => {
if (argv.mode === "development") {
config.output.filename = libraryFileName + ".js";
} else if (argv.mode === "production") {
config.output.filename = libraryFileName + ".min.js";
}
return config;
};