-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.partial.ts
More file actions
60 lines (56 loc) · 1.57 KB
/
Copy pathwebpack.partial.ts
File metadata and controls
60 lines (56 loc) · 1.57 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
import webpack from 'webpack';
import portfinder from 'portfinder';
import { fileURLToPath } from 'url';
import path from 'path';
import CopyWebpackPlugin from 'copy-webpack-plugin';
const {
DefinePlugin ,
ProvidePlugin,
} = webpack;
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const rootDir = path.resolve(__dirname , '../../');
export const webpackConfig = {/*be dynamic imported*/
entry : './src/index.tsx' ,
output : {
libraryTarget : 'module' ,
module : true ,
path : path.resolve(__dirname , 'dist') ,
filename : 'index.js' ,
} ,
devtool : 'source-map' ,
experiments : {
outputModule : true ,
} , // stats : 'errors-only' ,
externals : ['reaxes' , 'react' , 'react-dom' , 'react-router' , 'react-router-dom' , 'lodash' , 'mobx' , 'shallowequal'] ,
mode : 'production' ,
performance : {
maxEntrypointSize : 10000000 ,
maxAssetSize : 30000000 ,
} ,
plugins : [
getProvidePlugin() ,
new CopyWebpackPlugin({
patterns : [
{
from : path.resolve(__dirname,'./public/package.json') ,
to : path.resolve(__dirname,'./dist/package.json') ,
} ,
] ,
}) ,
] ,
};
function getProvidePlugin () {
return new ProvidePlugin({
_ : ['lodash'] ,
React : ['react'] ,
useState : ['react' , 'useState'] ,
useEffect : ['react' , 'useEffect'] ,
useRef : ['react' , 'useRef'] ,
useLayoutEffect : ['react' , 'useLayoutEffect'] ,
useMemo : ['react' , 'useMemo'] ,
useCallback : ['react' , 'useCallback'] ,
orzPromise : ['reaxes-utils' , 'orzPromise'] ,
utils : ['reaxes-utils'] ,
crayon : ['reaxes-utils' , 'crayon'] ,
});
}