File tree 3 files changed +17
-5
lines changed
3 files changed +17
-5
lines changed Original file line number Diff line number Diff line change 1
1
node_modules /
2
+ .vscode /
2
3
* .swp
Original file line number Diff line number Diff line change @@ -15,9 +15,18 @@ var serve = require("../lib/serve");
15
15
16
16
program . version ( pkg . version ) ;
17
17
18
+ const stringBooleanToBoolean = val => {
19
+ if ( typeof val !== 'string' && ( val !== 'true' || val !== 'false' ) ) {
20
+ throw Error ( `Incorrect string value: ${ val } ` ) ;
21
+ }
22
+
23
+ return val === 'true' ;
24
+ } ;
25
+
18
26
program
19
27
. option ( "-c --config <webpack-config>" , "additional webpack configuration" )
20
28
. option ( "-p --port <port>" , "port to serve from (default: 9000)" )
29
+ . option ( "-b --babelrc <no-babelrc>" , "use .babelrc in root (default: true)" , stringBooleanToBoolean )
21
30
. option (
22
31
"-t --timeout <timeout>" ,
23
32
"function invocation timeout in seconds (default: 10)"
@@ -57,8 +66,10 @@ program
57
66
. description ( "build functions" )
58
67
. action ( function ( cmd , options ) {
59
68
console . log ( "netlify-lambda: Building functions" ) ;
69
+
70
+ const { config : userWebpackConfig , babelrc : useBabelrc = true } = program ;
60
71
build
61
- . run ( cmd , program . config )
72
+ . run ( cmd , { userWebpackConfig , useBabelrc } )
62
73
. then ( function ( stats ) {
63
74
console . log ( stats . toString ( { color : true } ) ) ;
64
75
} )
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ function haveBabelrc(functionsDir) {
31
31
) ;
32
32
}
33
33
34
- function webpackConfig ( dir , additionalConfig ) {
34
+ function webpackConfig ( dir , { userWebpackConfig , useBabelrc } ) {
35
35
var config = conf . load ( ) ;
36
36
var envConfig = conf . loadContext ( config ) . environment ;
37
37
var babelOpts = { cacheDirectory : true } ;
@@ -88,7 +88,7 @@ function webpackConfig(dir, additionalConfig) {
88
88
) ,
89
89
use : {
90
90
loader : require . resolve ( 'babel-loader' ) ,
91
- options : babelOpts
91
+ options : { ... babelOpts , babelrc : useBabelrc }
92
92
}
93
93
}
94
94
]
@@ -129,8 +129,8 @@ function webpackConfig(dir, additionalConfig) {
129
129
`
130
130
) ;
131
131
}
132
- if ( additionalConfig ) {
133
- var webpackAdditional = require ( path . join ( process . cwd ( ) , additionalConfig ) ) ;
132
+ if ( userWebpackConfig ) {
133
+ var webpackAdditional = require ( path . join ( process . cwd ( ) , userWebpackConfig ) ) ;
134
134
135
135
return merge . smart ( webpackConfig , webpackAdditional ) ;
136
136
}
You can’t perform that action at this time.
0 commit comments