Closed tarciozemel closed 4 years ago
Any update on this?
Brunch is very good, but his community is dead...
Works for me.
Brunch: 3 Node.js: 12.6.1 NPM: 6.14.x
brunch-config.js
require('dotenv').config()
console.log(process.env.TEST_KEY)
...
$ npm start
> App@1.1.1 start /Users/reubano/Documents/Projects/app
> brunch watch --server
test_value
...
The key to getting dotenv
to work in files other than brunch-config.js
is process-env-brunch.
.env
TEST_KEY=fizz
app/config.js
console.log($PROCESS_ENV_TEST_KEY);
module.exports = {
...
}
Description
The essence of this issue is understand how to use env variables in code with Brunch.
More specificaly, in "overrides" section of config docs we found:
So I installed dotenv, create some variables in a
.env
file in the root of the project and try to:But the thing didn't goes very well...
Expected behavior
The expected behavior is something like the Create React App wepack environment variables autoimport: I put some vars in
.env
file and voilà!Environment
package.json
contentsbrunch config contents