middleman-dotenv
middleman-dotenv copied to clipboard
env set in development environment always prevail
It seems middleman will always load a development environment first, and then the target environment, be it a :build or :production
So even with the following code block in config.rb
configure :development do
puts "environment: #{app.environment}"
activate :dotenv, env: '.env.development'
p ENV
end
configure :production do
puts "environment: #{app.environment}"
activate :dotenv, env: '.env.production'
p ENV
end
with .env.* define the same variable with different values, the setting in development environment prevails.
If one variable is defined in development but not in production, it is also exposed in production environment.
@karlfreeman This looks like it can be solved by using ::Dotenv.overload instead of ::Dotenv.load This way the values loaded from the last target built are the values used. load will not overwrite the original environment variables when the first build is triggered.