diff --git a/lib/builder/webpack/client.config.js b/lib/builder/webpack/client.config.js
index 4e04e63df0..708bbd1263 100644
--- a/lib/builder/webpack/client.config.js
+++ b/lib/builder/webpack/client.config.js
@@ -76,7 +76,7 @@ export default function webpackClientConfig () {
// Env object defined in nuxt.config.js
let env = {}
each(this.options.env, (value, key) => {
- env['process.env.' + key] = (typeof value === 'string' ? JSON.stringify(value) : value)
+ env['process.env.' + key] = (['boolean', 'number'].indexOf(typeof value) !== -1 ? value : JSON.stringify(value))
})
// Webpack common plugins
diff --git a/lib/builder/webpack/server.config.js b/lib/builder/webpack/server.config.js
index 3b2b10478a..7009ed5603 100644
--- a/lib/builder/webpack/server.config.js
+++ b/lib/builder/webpack/server.config.js
@@ -17,7 +17,7 @@ export default function webpackServerConfig () {
// env object defined in nuxt.config.js
let env = {}
each(this.options.env, (value, key) => {
- env['process.env.' + key] = (typeof value === 'string' ? JSON.stringify(value) : value)
+ env['process.env.' + key] = (['boolean', 'number'].indexOf(typeof value) !== -1 ? value : JSON.stringify(value))
})
config = Object.assign(config, {
diff --git a/test/fixtures/with-config/nuxt.config.js b/test/fixtures/with-config/nuxt.config.js
index a17928867e..1c224bd14e 100644
--- a/test/fixtures/with-config/nuxt.config.js
+++ b/test/fixtures/with-config/nuxt.config.js
@@ -24,7 +24,15 @@ module.exports = {
env: {
bool: true,
num: 23,
- string: 'Nuxt.js'
+ string: 'Nuxt.js',
+ object: {
+ bool: true,
+ string: 'ok',
+ num2: 8.23,
+ obj: {
+ again: true
+ }
+ }
},
build: {
// extractCSS: true,
diff --git a/test/fixtures/with-config/pages/env.vue b/test/fixtures/with-config/pages/env.vue
index df9f95d882..5f65ca8d87 100644
--- a/test/fixtures/with-config/pages/env.vue
+++ b/test/fixtures/with-config/pages/env.vue
@@ -1,11 +1,20 @@
- {{ env }}
+
+
{{ env }}
+
object:
+
{{ processEnv }}
+
Home
+