Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use dotenv-safe #4

Closed
lucasbento opened this issue Aug 4, 2016 · 15 comments · Fixed by #5
Closed

Use dotenv-safe #4

lucasbento opened this issue Aug 4, 2016 · 15 comments · Fixed by #5

Comments

@lucasbento
Copy link
Contributor

Use dotenv-safe instead of dotenv.

@mrsteele
Copy link
Owner

mrsteele commented Aug 4, 2016

Thanks for the recommendation!

I saw someone else had created something similar to it, but for our workflow we don't really use it.

If you want, you can use webpack-dotenv-plugin which does just that: https://www.npmjs.com/package/webpack-dotenv-plugin

I don't think our packages are much different apart from that.

@mrsteele mrsteele self-assigned this Aug 4, 2016
@lucasbento
Copy link
Contributor Author

@mrsteele yeah, tried that one and did not work.

Anyway, thank you for yours!

@mrsteele
Copy link
Owner

mrsteele commented Aug 4, 2016

Didn't work really?

Did mine work? 😆

@mrsteele
Copy link
Owner

mrsteele commented Aug 4, 2016

I ask because if his is having problems, maybe I can look into incorporating dotenv-safe as an optional alternative:

const Dotenv = require('dotenv-webpack');

module.exports = {
  ...
  plugins: [
    new Dotenv({
      safe: true
    })
  ]
  ...
};

@lucasbento
Copy link
Contributor Author

@mrsteele I would not star it if it did not work haha 😆

All the other options that I tried failed with something similar to this issue: request/request#1529

That way you mentioned would be great.

mrsteele pushed a commit that referenced this issue Aug 4, 2016
@mrsteele
Copy link
Owner

mrsteele commented Aug 4, 2016

If you wanna guiny-pig this, I just did a feature branch to support this.

Options:

  • path (String) - The path to the env (defaults to ./.env
  • sample (String) - The path to the sample env (defaults to ./.env.example
  • safe (Bool) - If you want it to be on safe-mode (defaults to false)

The branch is feature/dotenv-safe. Let me know if that works like you want. Seems like a good addition.

@lucasbento
Copy link
Contributor Author

@mrsteele awesome!

If I stall from your branch it throws this error:
image

Do you know why?

It installs normally if I use the published package on npm.

@mrsteele
Copy link
Owner

mrsteele commented Aug 4, 2016

You probably need to npm i from the dir in node_modules.

cd ./node_modules/dotenv-webpack
npm i

@mrsteele
Copy link
Owner

mrsteele commented Aug 4, 2016

Might have to npm run build too to make sure you have the dist version if you are not running as es6.

@lucasbento
Copy link
Contributor Author

@mrsteele I will try it as soon as I get home.

@lucasbento
Copy link
Contributor Author

npm i git+https://github.com/mrsteele/dotenv-webpack.git#feature/dotenv-safe -D
cd node_modules/dotenv-webpack
npm i && npm run build

Throws an error because ./src folder does not get pulled, so I tried cloning everything than switching to the feature branch which throws the same error that we experienced yesterday.

@mrsteele
Copy link
Owner

mrsteele commented Aug 5, 2016

Well if you clone you would still need to build if your environment doesn't support Babel things.

  1. Clone
  2. npm i
  3. npm run build

That way you have all the dependencies, as well as access to the dist version of the plugin.

Matt Steele

On Aug 5, 2016, at 3:29 PM, Lucas Bento [email protected] wrote:

npm i git+https://github.com/mrsteele/dotenv-webpack.git#feature/dotenv-safe -D
cd node_modules/dotenv-webpack
npm i && npm run build
Throws an error because ./src folder does not get pulled, so I tried cloning everything than switching to the feature branch which throws the same error that we experienced yesterday.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

@mrsteele
Copy link
Owner

mrsteele commented Aug 6, 2016

Okay I finally have time to tackle this a bit.

Just realized something a little problematic with this. You have access to the dotenv but not the actual env variables of the machine.

Going to look into refactoring all of this in a little bit and i'll touch base when that is all done.

@lucasbento
Copy link
Contributor Author

Ok, cool.

@mrsteele
Copy link
Owner

mrsteele commented Aug 6, 2016

I got it all checked in and it is releasing as v1.1.0 as part of the CI release schedule.

Please check this specific version out and if you have any problems, please open a bug ticket.

Have a look at the new README.md file which displays the supported additional params to satisfy this need.

Thanks for the suggestion and all the help along the way!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants