File tree 1 file changed +11
-6
lines changed
1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,14 @@ function webpackConfig(dir, additionalConfig) {
22
22
] ;
23
23
}
24
24
25
+ var functionsDir = config . build . functions || config . build . Functions ;
26
+ var functionsPath = path . join ( process . cwd ( ) , functionsDir ) ;
27
+ var dirPath = path . join ( process . cwd ( ) , dir ) ;
28
+
29
+ if ( dirPath === functionsPath ) {
30
+ throw new Error ( "Function source directory and compiled directory are the same" ) ;
31
+ }
32
+
25
33
var webpackConfig = {
26
34
module : {
27
35
rules : [
@@ -35,21 +43,18 @@ function webpackConfig(dir, additionalConfig) {
35
43
}
36
44
]
37
45
} ,
38
- context : path . join ( process . cwd ( ) , dir ) ,
46
+ context : dirPath ,
39
47
entry : { } ,
40
48
target : "node" ,
41
49
plugins : [ new webpack . IgnorePlugin ( / v e r t x / ) ] ,
42
50
output : {
43
- path : path . join (
44
- process . cwd ( ) ,
45
- config . build . functions || config . build . Functions
46
- ) ,
51
+ path : functionsPath ,
47
52
filename : "[name].js" ,
48
53
libraryTarget : "commonjs"
49
54
} ,
50
55
devtool : false
51
56
} ;
52
- fs . readdirSync ( path . join ( process . cwd ( ) , dir ) ) . forEach ( function ( file ) {
57
+ fs . readdirSync ( dirPath ) . forEach ( function ( file ) {
53
58
if ( file . match ( / \. j s $ / ) ) {
54
59
var name = file . replace ( / \. j s $ / , "" ) ;
55
60
webpackConfig . entry [ name ] = "./" + name ;
You can’t perform that action at this time.
0 commit comments