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

Allow custom env for Webpacker #1350

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const defaultConfigPath = require.resolve('../lib/install/config/webpacker.yml')
const configPath = resolve('config', 'webpacker.yml')

const getConfig = () => {
const defaults = safeLoad(readFileSync(defaultConfigPath), 'utf8')[env]
const defaults = safeLoad(readFileSync(defaultConfigPath), 'utf8')[env] || {}
const app = safeLoad(readFileSync(configPath), 'utf8')[env]

if (isArray(app.extensions) && app.extensions.length) {
Expand Down
14 changes: 14 additions & 0 deletions test/env_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ def test_custom
end
end

def test_custom_with_user_defined
with_node_env("cucumber") do
reloaded_config
assert_equal Webpacker.env, "cucumber"
end
end

def test_fallback
with_node_env("not-defined") do
reloaded_config
assert_equal Webpacker.env, "production"
end
end

def test_default
assert_equal Webpacker::Env::DEFAULT, "production"
end
Expand Down
4 changes: 4 additions & 0 deletions test/test_app/config/webpacker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,7 @@ production:

# Cache manifest.json for performance
cache_manifest: true

cucumber:
<<: *default
compile: true