Skip to content

Commit

Permalink
fix: #1218 serverless offline now work with api gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
Cuong Vu committed May 22, 2020
1 parent 4f04330 commit d0d2e4b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/web-components/scripts/start-dev.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env node
const fs = require('fs')
const path = require('path')

const getMoveHtmlScript = packageName => {
switch (packageName) {
Expand Down Expand Up @@ -42,9 +43,14 @@ return (() => {
const clientScript = `rollup -w -c './scripts/rollup.config.${packageName}.js' --environment APP_ENV:local`
const serverConfigFile = `src/${packageName}/server/serverless.yml`
const hasServer = fs.existsSync(serverConfigFile)
// eslint-disable-next-line max-len
// need to pass the apiKey into serverless offline for it to work locally
const { WEB_COMPONENT_API_KEY_SEARCH_WIDGET } = require(path.resolve(__dirname, '../config.json'))
const apiKeys = {
'search-widget': WEB_COMPONENT_API_KEY_SEARCH_WIDGET,
}
const serverScript = hasServer
? `serverless offline --config ${serverConfigFile} --out public/dist --stage local`
? // eslint-disable-next-line max-len
`serverless offline --config ${serverConfigFile} --out public/dist --stage local --apiKey ${apiKeys[packageName]}`
: null
const startClientServer = getStartClientServer(packageName)

Expand Down

0 comments on commit d0d2e4b

Please sign in to comment.