Commit 1e6700d0 authored by Eric Betts's avatar Eric Betts

doesn't work, but trying to structure as a plugin

parent 9f8a6e8c
'use strict'
const dotenv = require('dotenv')
if (false) {
require('./.env') // So the file is included by netlify zip it and ship it
}
const result = dotenv.config()
if (result.error) {
throw result.error
console.log('dotenv error:', result.error)
}
console.log(result.parsed)
......
......@@ -16,3 +16,6 @@
[dev]
port = 9000
[[plugins]]
package = "/plugins/netlify-save-env"
......@@ -39,7 +39,7 @@
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"prebuild": "node write_env.js && netlify-lambda build functions",
"prebuild": "netlify-lambda build functions",
"postinstall": "netlify-lambda install"
},
"devDependencies": {
......
const fs = require('fs');
module.exports = {
onPreBuild: ({ constants }) => {
console.log('Hello world from onPreBuild event!')
const { FUNCTIONS_DIST, FUNCTIONS_SRC } = constants;
const keys = Object.keys(process.env);
const kvs = keys.map(key => `${key}=${process.env[key]}`);
fs.mkdirSync(FUNCTIONS_DIST);
fs.writeFileSync(`${FUNCTIONS_DIST}/.env`, kvs.join('\n'));
console.log(`Wrote ${kvs.length} envs to ${FUNCTIONS_DIST}/.env`);
},
}
const fs = require('fs');
const keys = Object.keys(process.env);
const kvs = keys.map(key => `${key}=${process.env[key]}`);
fs.writeFileSync('functions/.env', kvs.join('\n'));
console.log(`Wrote ${kvs.length} envs`);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment