reaxes-utils 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,205 @@
1
+ import webpack from 'webpack';
2
+ import portfinder from 'portfinder';
3
+ import { fileURLToPath } from 'url';
4
+ import _ from 'lodash';
5
+ import path from 'path';
6
+ import CopyWebpackPlugin from 'copy-webpack-plugin';
7
+
8
+ const {
9
+ DefinePlugin ,
10
+ ProvidePlugin,
11
+ } = webpack;
12
+
13
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
14
+
15
+ function getProvidePlugin () {
16
+ return new ProvidePlugin({
17
+ _ : ["lodash"] ,
18
+ React : ["react"] ,
19
+ useState : [
20
+ "react" ,
21
+ "useState" ,
22
+ ] ,
23
+ useEffect : [
24
+ "react" ,
25
+ "useEffect" ,
26
+ ] ,
27
+ useRef : [
28
+ "react" ,
29
+ "useRef" ,
30
+ ] ,
31
+ useLayoutEffect : [
32
+ "react" ,
33
+ "useLayoutEffect" ,
34
+ ] ,
35
+ useMemo : [
36
+ "react" ,
37
+ "useMemo" ,
38
+ ] ,
39
+ useCallback : [
40
+ "react" ,
41
+ "useCallback" ,
42
+ ] ,
43
+ });
44
+ };
45
+
46
+ const packages = path.resolve(__dirname , "../");
47
+ const getPort = () => {
48
+ portfinder.basePort = 8080;
49
+ return portfinder.getPortPromise();
50
+ };
51
+ const cssLoaderOptions = {
52
+ sourceMap : true ,
53
+ modules : {
54
+ exportLocalsConvention : "dashes" ,
55
+ localIdentName : "[local]--[hash:base64:4]" ,
56
+
57
+ } ,
58
+ };
59
+
60
+
61
+ export default {
62
+ entry : "./src/index.tsx" ,
63
+ output : {
64
+ libraryTarget : "module" ,
65
+ module : true ,
66
+ path : path.resolve(__dirname , 'dist') ,
67
+ filename : "index.js" ,
68
+ } ,
69
+ resolve : {
70
+ alias : {
71
+ '@@root' : __dirname ,
72
+ '@@packages/*' : path.resolve(__dirname , "../") ,
73
+ '@@utils/*' : path.resolve(__dirname , 'src/*') ,
74
+ } ,
75
+ extensions : [
76
+ '.ts' ,
77
+ '.tsx' ,
78
+ '.js' ,
79
+ '.jsx' ,
80
+ '.json' ,
81
+ ] ,
82
+ } ,
83
+ devtool : 'source-map' ,
84
+ experiments : {
85
+ outputModule : true ,
86
+ } , // stats : 'errors-only' ,
87
+ module : {
88
+ rules : [
89
+ {
90
+ test : /\.(jsx?|tsx?)$/ ,
91
+ use : {
92
+ loader : 'babel-loader' ,
93
+ options : {
94
+ sourceMap : true ,
95
+ } ,
96
+ } ,
97
+ exclude : /node_modules/ ,
98
+ } ,
99
+ {
100
+ test : /\.module\.less$/ ,
101
+ use : [
102
+ {
103
+ loader : 'style-loader' ,
104
+ } ,
105
+ {
106
+ loader : 'css-loader' ,
107
+ options : cssLoaderOptions ,
108
+ } ,
109
+ {
110
+ loader : 'less-loader' ,
111
+ options : {
112
+ sourceMap : true ,
113
+ lessOptions : {
114
+ javascriptEnabled : true ,
115
+ } ,
116
+ } ,
117
+ } ,
118
+ ] ,
119
+ } ,
120
+ {
121
+ test : /(?<!\.module)\.less$/ ,
122
+ use : [
123
+ {
124
+ loader : 'style-loader' ,
125
+ } ,
126
+ {
127
+ loader : 'css-loader' ,
128
+ options : _.pick(cssLoaderOptions , ["sourceMap"]) ,
129
+ } ,
130
+ {
131
+ loader : 'less-loader' ,
132
+ options : {
133
+ sourceMap : true ,
134
+ lessOptions : {
135
+ javascriptEnabled : true ,
136
+ } ,
137
+ } ,
138
+ } ,
139
+ ] ,
140
+ } ,
141
+ {
142
+ test : /\.module\.css$/ ,
143
+ use : [
144
+ {
145
+ loader : 'style-loader' ,
146
+ } ,
147
+ {
148
+ loader : 'css-loader' ,
149
+ options : cssLoaderOptions ,
150
+ } ,
151
+ ] ,
152
+ } ,
153
+ {
154
+ test : /(?<!\.module)\.css$/ ,
155
+ use : [
156
+ {
157
+ loader : 'style-loader' ,
158
+ } ,
159
+ {
160
+ loader : 'css-loader' ,
161
+ options : _.pick(cssLoaderOptions , ["sourceMap"]) ,
162
+ } ,
163
+ ] ,
164
+ } ,
165
+ {
166
+ test : /\.(png|jpe?g|te?xt|gif|woff|woff2|eot|ttf|otf|bmp|swf)$/ ,
167
+ type : "asset/resource" ,
168
+ generator : {
169
+ filename : 'static/[hash][ext][query]' ,
170
+ } ,
171
+ parser : {
172
+ dataUrlCondition : {
173
+ maxSize : 20 * 1024 ,
174
+ } ,
175
+ } ,
176
+ } ,
177
+ {
178
+ test : /\.component\.svg$/ ,
179
+ use : ["@svgr/webpack"] ,
180
+
181
+ } ,
182
+ {
183
+ test : /(?<!\.component)\.svg$/ ,
184
+ type : "asset/resource" ,
185
+
186
+ } ,
187
+ ] ,
188
+ } ,
189
+ mode : "production" ,
190
+ performance : {
191
+ maxEntrypointSize : 10000000 ,
192
+ maxAssetSize : 30000000 ,
193
+ } ,
194
+ plugins : [
195
+ getProvidePlugin() ,
196
+ new CopyWebpackPlugin({
197
+ patterns : [
198
+ {
199
+ from : "src/types.d.ts" ,
200
+ to : "types.d.ts" ,
201
+ },
202
+ ],
203
+ }),
204
+ ] ,
205
+ };