@@ -7,15 +7,9 @@ interface NetlifyUtils {
7
7
} ;
8
8
}
9
9
10
- interface NetlifyConstants {
11
- BUILD_DIR : string ;
12
- }
13
-
14
10
interface NetlifyOpts {
15
11
utils : NetlifyUtils ;
16
- constants : NetlifyConstants ;
17
- inputs : Record < string , any > ;
18
- netlifyConfig : Record < string , any > ;
12
+ netlifyConfig : { build : { base : string } } ;
19
13
}
20
14
21
15
const buildCachePath = '.next' ;
@@ -27,22 +21,11 @@ module.exports = {
27
21
// Does not do anything if:
28
22
// - the file/directory already exists locally
29
23
// - the file/directory has not been cached yet
30
- async onPreBuild ( { utils, constants, inputs, netlifyConfig} : NetlifyOpts ) {
31
- console . debug ( '<- DEBUG ->' ) ;
32
- console . debug ( '<- CONSTANTS ->' ) ;
33
- console . debug ( constants ) ;
34
- console . debug ( '<- CONSTANTS ->' ) ;
35
- console . debug ( '<- INPUTS ->' ) ;
36
- console . debug ( inputs ) ;
37
- console . debug ( '<- INPUTS ->' ) ;
38
- console . debug ( '<- CONFIG ->' ) ;
39
- console . log ( netlifyConfig ) ;
40
- console . debug ( '<- CONFIG ->' ) ;
41
- console . debug ( '<- DEBUG ->' ) ;
42
- const directory = joinPaths ( constants . BUILD_DIR , buildCachePath ) ;
24
+ async onPreBuild ( { utils, netlifyConfig} : NetlifyOpts ) {
25
+ const directory = joinPaths ( netlifyConfig . build . base , buildCachePath ) ;
43
26
44
27
const success = await utils . cache . restore ( directory , {
45
- digest : [ joinPaths ( constants . BUILD_DIR , manifestPath ) ]
28
+ digest : [ joinPaths ( netlifyConfig . build . base , manifestPath ) ]
46
29
} ) ;
47
30
48
31
if ( success ) {
@@ -57,11 +40,11 @@ module.exports = {
57
40
// - the file/directory is already cached and its contents has not changed
58
41
// If this is a directory, this includes children's contents
59
42
// Note that this will cache after the build, even if it fails, which fcould be unwanted behavior
60
- async onPostBuild ( { utils, constants } : NetlifyOpts ) {
61
- const directory = joinPaths ( constants . BUILD_DIR , buildCachePath ) ;
43
+ async onPostBuild ( { utils, netlifyConfig } : NetlifyOpts ) {
44
+ const directory = joinPaths ( netlifyConfig . build . base , buildCachePath ) ;
62
45
63
46
const success = await utils . cache . save ( directory , {
64
- digest : [ joinPaths ( constants . BUILD_DIR , manifestPath ) ]
47
+ digest : [ joinPaths ( netlifyConfig . build . base , manifestPath ) ]
65
48
} ) ;
66
49
67
50
if ( success ) {
0 commit comments