Created
June 18, 2018 11:24
-
-
Save paulbjensen/91ffc051331c42e9908ab178478f5a09 to your computer and use it in GitHub Desktop.
The generateWebConfig.js file, part of an article on Medium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Writes a file to src/config.js exporting the baseUrl property | |
const config = require('../config'); | |
const fs = require('fs'); | |
const path = require('path'); | |
const { | |
baseUrl, | |
googleAnalytics, | |
sentryDSN, | |
useDevTools, | |
env, | |
secureCookie, | |
apiVersion | |
} = config; | |
const template = `const baseUrl = '${baseUrl}'; | |
const googleAnalytics = '${googleAnalytics}'; | |
const sentryDSN = '${sentryDSN}'; | |
const useDevTools = ${useDevTools}; | |
const secureCookie = ${secureCookie}; | |
const apiVersion = '${apiVersion}'; | |
export { | |
baseUrl, | |
googleAnalytics, | |
sentryDSN, | |
secureCookie, | |
useDevTools, | |
apiVersion | |
};`; | |
const filePath = path.join(process.cwd(), 'src/config.js'); | |
fs.writeFile(filePath, template, err => { | |
console.log(`Generated config for web for ${env}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment