Test Next public env vars (#1006)

* test next public env vars

* make next.config.js smaller
main
Michael Fix 4 years ago committed by GitHub
parent b000e7093c
commit a507b07dc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -265,7 +265,7 @@ const BillingWithStripe = injectStripe(Billing)
export default function () {
const [stripe, setStripe] = React.useState(null)
React.useEffect(() => {
setStripe(window.Stripe(process.env.STRIPE_PUBLIC_KEY))
setStripe(window.Stripe(process.env.NEXT_PUBLIC_STRIPE_PUBLIC_KEY))
}, [])
return (
<StripeProvider stripe={stripe}>

@ -8,7 +8,7 @@ import firebase from './client'
import { DEFAULT_CODE, DEFAULT_SETTINGS } from './constants'
export const client = axios.create({
baseURL: `${process.env.API_URL || ''}/api`,
baseURL: `${process.env.NEXT_PUBLIC_API_URL || ''}/api`,
headers: {
Accept: 'application/json',
},

@ -2,15 +2,15 @@ import * as firebase from 'firebase/app'
import 'firebase/auth'
if (firebase.apps.length === 0) {
if (process.env.FIREBASE_API_KEY && process.env.FIREBASE_FE_APP_ID) {
if (process.env.NEXT_PUBLIC_FIREBASE_API_KEY && process.env.NEXT_PUBLIC_FIREBASE_FE_APP_ID) {
firebase.initializeApp({
apiKey: process.env.FIREBASE_API_KEY,
authDomain: `${process.env.FIREBASE_PROJECT_ID}.firebaseapp.com`,
databaseURL: `https://${process.env.FIREBASE_PROJECT_ID}.firebaseio.com`,
projectId: process.env.FIREBASE_PROJECT_ID,
storageBucket: `${process.env.FIREBASE_PROJECT_ID}.appspot.com`,
messagingSenderId: process.env.FIREBASE_MESSAGING_SENDER_ID,
appId: process.env.FIREBASE_FE_APP_ID,
apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
authDomain: `${process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID}.firebaseapp.com`,
databaseURL: `https://${process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID}.firebaseio.com`,
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
storageBucket: `${process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID}.appspot.com`,
messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID,
appId: process.env.NEXT_PUBLIC_FIREBASE_FE_APP_ID,
})
}
}

@ -1,31 +1,24 @@
const bundleAnalyzer = require('@next/bundle-analyzer')
const withOffline = require('next-offline')
const withBundleAnalyzer = bundleAnalyzer({ enabled: true })
const withBundleAnalyzer = bundleAnalyzer({ enabled: process.env.ANALYZE === 'true' })
const config = withOffline({
target: 'serverless',
dontAutoRegisterSw: true,
// https://github.com/hanford/next-offline/blob/master/packages/now2-example/next.config.js
workboxOpts: {
swDest: 'static/service-worker.js',
},
env: {
FIREBASE_PROJECT_ID: process.env.FIREBASE_PROJECT_ID,
FIREBASE_MESSAGING_SENDER_ID: process.env.FIREBASE_MESSAGING_SENDER_ID,
FIREBASE_FE_APP_ID: process.env.FIREBASE_FE_APP_ID,
FIREBASE_API_KEY: process.env.FIREBASE_API_KEY,
STRIPE_PUBLIC_KEY: process.env.STRIPE_PUBLIC_KEY,
},
webpack: (config, options) => {
config.module.rules.push({
test: /\.js$/,
include: /node_modules\/graphql-language-service-parser/,
use: [options.defaultLoaders.babel],
})
module.exports = withBundleAnalyzer(
withOffline({
target: 'serverless',
dontAutoRegisterSw: true,
// https://github.com/hanford/next-offline/blob/master/packages/now2-example/next.config.js
workboxOpts: {
swDest: 'static/service-worker.js',
},
webpack: (config, options) => {
config.module.rules.push({
test: /\.js$/,
include: /node_modules\/graphql-language-service-parser/,
use: [options.defaultLoaders.babel],
})
return config
},
})
module.exports = process.env.ANALYZE === 'true' ? withBundleAnalyzer(config) : config
return config
},
})
)

@ -59,16 +59,6 @@
},
{ "handle": "filesystem" }
],
"build": {
"env": {
"NODE_ENV": "production",
"FIREBASE_PROJECT_ID": "@carbon-firebase-project-id",
"FIREBASE_MESSAGING_SENDER_ID": "@carbon-firebase-messaging-sender-id",
"FIREBASE_FE_APP_ID": "@carbon-firebase-fe-app-id",
"FIREBASE_API_KEY": "@carbon-firebase-api-key",
"STRIPE_PUBLIC_KEY": "@carbon-stripe-public-key"
}
},
"github": {
"autoAlias": false,
"silent": true

Loading…
Cancel
Save