File tree Expand file tree Collapse file tree 1 file changed +35
-1
lines changed Expand file tree Collapse file tree 1 file changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,41 @@ const nextConfig = {
8
8
unoptimized : true ,
9
9
} ,
10
10
webpack : function ( config , { isServer } ) {
11
- config . experiments = { asyncWebAssembly : true } ;
11
+ config . experiments = { layers : true , asyncWebAssembly : true } ;
12
+
13
+ const { join } = require ( 'path' ) ;
14
+ const { access, symlink } = require ( 'fs/promises' ) ;
15
+ config . plugins . push (
16
+ new ( class {
17
+ apply ( compiler ) {
18
+ compiler . hooks . afterEmit . tapPromise (
19
+ 'SymlinkWebpackPlugin' ,
20
+ async ( compiler ) => {
21
+ if ( isServer ) {
22
+ const from = join ( compiler . options . output . path , '../static' ) ;
23
+ const to = join ( compiler . options . output . path , 'static' ) ;
24
+
25
+ try {
26
+ await access ( from ) ;
27
+ // console.log(`${from} already exists`);
28
+ return ;
29
+ } catch ( error ) {
30
+ if ( error . code === 'ENOENT' ) {
31
+ // No link exists
32
+ } else {
33
+ throw error ;
34
+ }
35
+ }
36
+
37
+ await symlink ( to , from , 'junction' ) ;
38
+ console . log ( `created symlink ${ from } -> ${ to } ` ) ;
39
+ }
40
+ } ,
41
+ ) ;
42
+ }
43
+ } ) ( ) ,
44
+ ) ;
45
+
12
46
return config ;
13
47
}
14
48
} ;
You can’t perform that action at this time.
0 commit comments