Test Next public env vars (#1006)

* test next public env vars

* make next.config.js smaller
main
Michael Fix 5 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 () { export default function () {
const [stripe, setStripe] = React.useState(null) const [stripe, setStripe] = React.useState(null)
React.useEffect(() => { React.useEffect(() => {
setStripe(window.Stripe(process.env.STRIPE_PUBLIC_KEY)) setStripe(window.Stripe(process.env.NEXT_PUBLIC_STRIPE_PUBLIC_KEY))
}, []) }, [])
return ( return (
<StripeProvider stripe={stripe}> <StripeProvider stripe={stripe}>

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

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

@ -1,22 +1,16 @@
const bundleAnalyzer = require('@next/bundle-analyzer') const bundleAnalyzer = require('@next/bundle-analyzer')
const withOffline = require('next-offline') const withOffline = require('next-offline')
const withBundleAnalyzer = bundleAnalyzer({ enabled: true }) const withBundleAnalyzer = bundleAnalyzer({ enabled: process.env.ANALYZE === 'true' })
const config = withOffline({ module.exports = withBundleAnalyzer(
withOffline({
target: 'serverless', target: 'serverless',
dontAutoRegisterSw: true, dontAutoRegisterSw: true,
// https://github.com/hanford/next-offline/blob/master/packages/now2-example/next.config.js // https://github.com/hanford/next-offline/blob/master/packages/now2-example/next.config.js
workboxOpts: { workboxOpts: {
swDest: 'static/service-worker.js', 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) => { webpack: (config, options) => {
config.module.rules.push({ config.module.rules.push({
test: /\.js$/, test: /\.js$/,
@ -26,6 +20,5 @@ const config = withOffline({
return config return config
}, },
}) })
)
module.exports = process.env.ANALYZE === 'true' ? withBundleAnalyzer(config) : config

@ -59,16 +59,6 @@
}, },
{ "handle": "filesystem" } { "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": { "github": {
"autoAlias": false, "autoAlias": false,
"silent": true "silent": true

Loading…
Cancel
Save