-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
webpack.config.js
99 lines (95 loc) · 2.81 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
var webpack = require("webpack"),
terserPlugin = require("terser-webpack-plugin"),
_ = require("lodash"),
fs = require("fs");
function createBanner() {
var pkg = JSON.parse(fs.readFileSync("./package.json"));
return "[name]\n" +
`${pkg.homepage}\n` +
`Copyright (c) 2010 - ${new Date().getFullYear()} ${pkg.author.name}\n` +
`Licensed under the ${pkg.license} license\n` +
`Version: ${pkg.version}`;
}
var rules = {
js: {
test: /\.js$/,
loader: "babel-loader",
exclude: /(node_modules)/,
options: {
presets: ["@babel/preset-env"],
plugins: ["@babel/plugin-transform-modules-commonjs"],
passPerPreset: true,
},
},
ts: {
test: /\.tsx?$/,
loader: "babel-loader",
exclude: /(node_modules)/,
options: {
presets: ["@babel/preset-typescript"],
passPerPreset: true,
},
}
};
module.exports = function (env, argv) {
var config = {
name: "main",
entry: {
"/dist/inputmask.libphonenumber.extensions": "./lib/inputmask.libphonenumber.extensions.js",
"/dist/inputmask.phone.extensions": "./lib/inputmask.phone.extensions.js",
"/qunit/qunit": "./qunit/index.js"
},
output: {
path: __dirname,
filename: "[name].js",
libraryTarget: "umd"
},
externals: {
"inputmask": "Inputmask",
"jquery": "jQuery",
"qunit": "QUnit"
},
optimization: {
minimize: env === "production",
minimizer: [new terserPlugin({
include: /\.min\.js$/,
terserOptions: {
sourceMap: env !== "production",
format: {
ascii_only: true,
beautify: false,
comments: /^!/
}
},
extractComments: false
}), new terserPlugin({
exclude: /\.min\.js$/,
terserOptions: {
sourceMap: env !== "production",
format: {
ascii_only: true,
beautify: true,
comments: /^!/
}
},
extractComments: false
})]
},
module: {
rules: [
rules.js,
rules.ts
]
},
devtool: "source-map",
plugins: [
new webpack.BannerPlugin({
banner: createBanner,
entryOnly: true
})
],
bail: true,
mode: env === "production" ? "production" : "none"
};
return [config];
};