-
Notifications
You must be signed in to change notification settings - Fork 32
/
webpack.config.js
78 lines (73 loc) · 2.23 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
const path = require("path");
const TerserPlugin = require("terser-webpack-plugin");
const webpack = require("webpack");
const version = require("./package.json").version;
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
const banner = `Author : Matteo Bruni - https://www.matteobruni.it
MIT license: https://opensource.org/licenses/MIT
Demo / Generator : https://editor.matteobruni.it/
GitHub : https://www.github.com/matteobruni/object-gui
How to use? : Check the GitHub README
v${version}`;
const minBanner = `ObjectGUI v${version} by Matteo Bruni`;
const getJsConfig = (entry) => {
const reportFileName = "report";
return {
entry: entry,
output: {
path: path.resolve(__dirname, "dist"),
filename: "[name].js",
libraryTarget: "umd",
globalObject: "this"
},
resolve: {
extensions: [".js", ".json"]
},
module: {
rules: [
{
// Include ts, tsx, js, and jsx files.
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader"
}
]
},
plugins: [
new webpack.BannerPlugin({
banner,
exclude: /\.min\.js$/
}),
new webpack.BannerPlugin({
banner: minBanner,
include: /\.min\.js$/
}),
new BundleAnalyzerPlugin({
openAnalyzer: false,
analyzerMode: "static",
exclude: /\.min\.js$/,
reportFilename: `${reportFileName}.html`
})
],
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
include: /\.min\.js$/,
terserOptions: {
output: {
comments: minBanner
}
},
extractComments: false
})
]
}
};
};
module.exports = [
getJsConfig({
"js/object-gui": "./dist/js/index.js",
"js/object-gui.min": "./dist/js/index.js"
})
];