1
1
import { dirname , resolve } from 'path' ;
2
2
import { fileURLToPath } from 'url' ;
3
3
import WebExtWebpackPlugin from '@leo60228/web-ext-webpack-plugin' ;
4
+ import { createRequire } from 'module' ;
5
+ import webpack from 'webpack' ;
6
+
7
+ const require = createRequire ( import . meta. url ) ;
4
8
5
9
const cwd = dirname ( fileURLToPath ( import . meta. url ) ) ;
6
10
const addonDir = resolve ( cwd , 'addon' ) ;
@@ -10,6 +14,7 @@ const config = env => ({
10
14
devtool : env . production ? 'source-map' : 'cheap-source-map' ,
11
15
entry : {
12
16
content_script : './lib/content.js' ,
17
+ background_script : './lib/background.js' ,
13
18
options_page : './lib/optionsPage.js' ,
14
19
} ,
15
20
output : {
@@ -26,6 +31,10 @@ const config = env => ({
26
31
firefoxProfile : resolve ( cwd , '.ff-profile' ) ,
27
32
profileCreateIfMissing : true ,
28
33
keepProfileChanges : true
34
+ } ) ,
35
+ new webpack . ProvidePlugin ( {
36
+ process : 'process/browser' ,
37
+ Buffer : 'buffer/'
29
38
} )
30
39
] ,
31
40
node : {
@@ -42,6 +51,13 @@ const config = env => ({
42
51
type : 'asset/source'
43
52
}
44
53
]
54
+ } ,
55
+ resolve : {
56
+ fallback : {
57
+ path : require . resolve ( 'path-browserify' ) ,
58
+ assert : require . resolve ( 'assert/' ) ,
59
+ fs : false
60
+ }
45
61
}
46
62
} ) ;
47
63
0 commit comments