-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.cjs
174 lines (170 loc) · 4.92 KB
/
webpack.config.cjs
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const webpack = require("webpack");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const WorkboxPlugin = require("workbox-webpack-plugin");
module.exports = [
// lib bundle
{
performance: {
hints: false,
},
experiments: {
asyncWebAssembly: true,
},
resolve: {
fallback: {
buffer: require.resolve("buffer/"),
stream: require.resolve("stream-browserify"),
path: require.resolve("path-browserify"),
fs: false,
},
},
node: {
global: true,
},
optimization: {
minimize: true,
},
entry: "./src/js/LiquidWallet.js",
output: {
filename: "liquidwallet.lib.js",
path: path.resolve(__dirname, "dist", "lib"),
library: {
name: "LiquidWallet",
type: "umd", // Universal module definition
export: "LiquidWallet",
},
globalObject: "this",
},
plugins: [
new webpack.ProvidePlugin({
Buffer: ["buffer", "Buffer"],
}),
],
mode: "production",
},
// extra css for embedding full page
{
performance: {
hints: false,
},
entry: "./src/less/page.less",
output: {
path: path.resolve(__dirname, "dist", "app"),
},
module: {
rules: [
{
test: /\.less$/,
use: [MiniCssExtractPlugin.loader, "css-loader", "less-loader"],
},
],
},
plugins: [
new MiniCssExtractPlugin({
filename: "page.css",
}),
],
mode: "production",
},
// ui bundle
{
// stats: {
// warningsFilter: warning => {
// return warning.startsWith("GenerateSW has been called multiple times")
// },
// },
performance: {
hints: false,
},
experiments: {
asyncWebAssembly: true,
},
resolve: {
fallback: {
buffer: require.resolve("buffer/"),
stream: require.resolve("stream-browserify"),
path: require.resolve("path-browserify"),
fs: false,
},
},
node: {
global: true,
},
entry: "./src/js/index.js",
output: {
filename: "liquidwallet.js",
path: path.resolve(__dirname, "dist", "app"),
},
plugins: [
new webpack.ProvidePlugin({
Buffer: ["buffer", "Buffer"],
}),
new HtmlWebpackPlugin({
template: "./src/assets/app/index.html",
filename: "index.html",
}),
new MiniCssExtractPlugin({
filename: "ui.css",
}),
new CopyWebpackPlugin({
patterns: [
{
from: path.resolve(__dirname, "src", "assets", "app"),
to: path.resolve(__dirname, "dist", "app"),
globOptions: {
ignore: ["**/index.html"],
},
},
],
}),
...(!process.env.WEBPACK_DEV_SERVER
? [
new WorkboxPlugin.GenerateSW({
maximumFileSizeToCacheInBytes: 5000000, // 5MB
clientsClaim: true,
skipWaiting: true,
}),
]
: []),
],
module: {
rules: [
{
test: /\.less$/,
use: [MiniCssExtractPlugin.loader, "css-loader", "less-loader"],
},
],
},
mode: process.env.BUILD_MODE === "production" ? "production" : "development",
},
{
performance: {
hints: false,
},
entry: "./src/assets/pack.js",
devServer: {
static: {
directory: path.join(__dirname, "dist"),
},
compress: false,
port: 9000,
},
plugins: [
new CopyWebpackPlugin({
patterns: [
{
from: path.resolve(__dirname, "src", "assets"),
to: path.resolve(__dirname, "dist"),
globOptions: {
ignore: ["**/app"],
},
},
],
}),
],
mode: "production",
},
];