-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.common.js
More file actions
109 lines (105 loc) · 2.32 KB
/
webpack.common.js
File metadata and controls
109 lines (105 loc) · 2.32 KB
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
100
101
102
103
104
105
106
107
108
109
const package = require("./package.json")
const path = require('path');
const webpack = require("webpack");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const TerserPlugin = require("terser-webpack-plugin");
function version_str_to_int(version) {
let i, out;
const version_list = version.split(".");
i = version_list.length;
out = 0x0;
while (i != 0x0) {
out = out | (Number(version_list[i - 0x1]) << (0x8 * (version_list.length - i)));
i--;
}
return (out);
}
function version_int_to_str(version, min) {
let out, i;
const list = [];
while (version != 0x0) {
list.unshift(version & 0xFF);
version = version >> 0x8;
}
while (list.length < min) {
list.unshift(0x0);
}
out = "";
i = 0x0;
while (true) {
out = out + String(list[i]).padStart(2, '0');
i++;
if (i < list.length) {
out = out + ".";
continue;
}
break;
}
return (out);
}
const web_tools_version = version_int_to_str(version_str_to_int(package.version), 0x3);
function func_common(env, argv, entry_patch, out_filename, library_name) {
const web_tools_beta = ((argv.mode == "development"))? true:false;
const tester_plugin_options =
{
terserOptions: { format: {comments: false,},},
extractComments: false
};
const tester_plugin = new TerserPlugin(tester_plugin_options);
const optimization =
{
minimize: true,
minimizer: [tester_plugin],
};
const config =
{
plugins: [
new MiniCssExtractPlugin(),
new webpack.DefinePlugin({
__VERSION__: JSON.stringify(web_tools_version),
__BETA__: JSON.stringify(web_tools_beta),
})
],
entry: entry_patch,
module:
{
rules:
[
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
{
test: /\.html$/i,
loader: "html-loader",
},
{
test: /\.scss$/i,
use: [MiniCssExtractPlugin.loader, "css-loader", "sass-loader"],
},
],
},
resolve:
{
extensions: ['.tsx', '.ts', '.js'],
},
output:
{
clean: true,
filename: out_filename,
libraryTarget: 'umd',
library: library_name,
path: path.resolve(__dirname, 'build')
}
};
if (argv.mode == "development")
config["devtool"] = 'source-map';
else {
config["devtool"] = false;
config["optimization"] = optimization;
}
return (config);
};
module.exports.common = func_common;
module.exports.web_tools_version = web_tools_version