-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #197 from gauravtiwari/fix/node_env
Use NODE_ENV as default env
- Loading branch information
Showing
6 changed files
with
38 additions
and
5 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Singleton registry for determining NODE_ENV from config/webpack/paths.yml | ||
require "webpacker/file_loader" | ||
|
||
class Webpacker::Env < Webpacker::FileLoader | ||
class << self | ||
def current | ||
raise Webpacker::FileLoader::FileLoaderError.new("Webpacker::Env.load must be called first") unless instance | ||
instance.data | ||
end | ||
|
||
def development? | ||
current == "development" | ||
end | ||
|
||
def file_path | ||
Rails.root.join("config", "webpack", "paths.yml") | ||
end | ||
end | ||
|
||
private | ||
def load | ||
environments = File.exist?(@path) ? YAML.load(File.read(@path)).keys : [].freeze | ||
return ENV["NODE_ENV"] if environments.include?(ENV["NODE_ENV"]) | ||
return Rails.env if environments.include?(Rails.env) | ||
"production" | ||
end | ||
end |
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
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