diff --git a/package/config.js b/package/config.js index 24390690c..879c15e61 100644 --- a/package/config.js +++ b/package/config.js @@ -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) { diff --git a/test/env_test.rb b/test/env_test.rb index 1fc743011..63633dc77 100644 --- a/test/env_test.rb +++ b/test/env_test.rb @@ -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 diff --git a/test/test_app/config/webpacker.yml b/test/test_app/config/webpacker.yml index beaf1831c..2fe50b351 100644 --- a/test/test_app/config/webpacker.yml +++ b/test/test_app/config/webpacker.yml @@ -61,3 +61,7 @@ production: # Cache manifest.json for performance cache_manifest: true + +cucumber: + <<: *default + compile: true