File tree Expand file tree Collapse file tree 3 files changed +17
-5
lines changed Expand file tree Collapse file tree 3 files changed +17
-5
lines changed Original file line number Diff line number Diff line change 11node_modules /
2+ .vscode /
23* .swp
Original file line number Diff line number Diff line change @@ -15,9 +15,18 @@ var serve = require("../lib/serve");
1515
1616program . version ( pkg . version ) ;
1717
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+
1826program
1927 . option ( "-c --config <webpack-config>" , "additional webpack configuration" )
2028 . option ( "-p --port <port>" , "port to serve from (default: 9000)" )
29+ . option ( "-b --babelrc <no-babelrc>" , "use .babelrc in root (default: true)" , stringBooleanToBoolean )
2130 . option (
2231 "-t --timeout <timeout>" ,
2332 "function invocation timeout in seconds (default: 10)"
@@ -57,8 +66,10 @@ program
5766 . description ( "build functions" )
5867 . action ( function ( cmd , options ) {
5968 console . log ( "netlify-lambda: Building functions" ) ;
69+
70+ const { config : userWebpackConfig , babelrc : useBabelrc = true } = program ;
6071 build
61- . run ( cmd , program . config )
72+ . run ( cmd , { userWebpackConfig , useBabelrc } )
6273 . then ( function ( stats ) {
6374 console . log ( stats . toString ( { color : true } ) ) ;
6475 } )
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ function haveBabelrc(functionsDir) {
3131 ) ;
3232}
3333
34- function webpackConfig ( dir , additionalConfig ) {
34+ function webpackConfig ( dir , { userWebpackConfig , useBabelrc } ) {
3535 var config = conf . load ( ) ;
3636 var envConfig = conf . loadContext ( config ) . environment ;
3737 var babelOpts = { cacheDirectory : true } ;
@@ -88,7 +88,7 @@ function webpackConfig(dir, additionalConfig) {
8888 ) ,
8989 use : {
9090 loader : require . resolve ( 'babel-loader' ) ,
91- options : babelOpts
91+ options : { ... babelOpts , babelrc : useBabelrc }
9292 }
9393 }
9494 ]
@@ -129,8 +129,8 @@ function webpackConfig(dir, additionalConfig) {
129129 `
130130 ) ;
131131 }
132- if ( additionalConfig ) {
133- var webpackAdditional = require ( path . join ( process . cwd ( ) , additionalConfig ) ) ;
132+ if ( userWebpackConfig ) {
133+ var webpackAdditional = require ( path . join ( process . cwd ( ) , userWebpackConfig ) ) ;
134134
135135 return merge . smart ( webpackConfig , webpackAdditional ) ;
136136 }
You can’t perform that action at this time.
0 commit comments