https://github.com/srph/node-stringify-object-values
Stringify an object's values
https://github.com/srph/node-stringify-object-values
defineplugin env webpack
Last synced: 5 months ago
JSON representation
Stringify an object's values
- Host: GitHub
- URL: https://github.com/srph/node-stringify-object-values
- Owner: srph
- Created: 2016-08-14T06:02:41.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2020-07-30T12:12:17.000Z (almost 6 years ago)
- Last Synced: 2025-05-17T11:16:28.485Z (about 1 year ago)
- Topics: defineplugin, env, webpack
- Language: JavaScript
- Size: 2.93 KB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
## stringify-object-values [](https://npmjs.org/package/stringify-object-values) [](https://travis-ci.org/srph/node-stringify-object-values?branch=master)
```
npm i stringify-object-values
```
Stringifies each value of an object. This is useful when paired with [Webpack's DefinePlugin](https://webpack.github.io/docs/list-of-plugins.html#defineplugin).
## Usage
```js
var stringify = require('stringify-object-values');
stringify({
hello: 'world',
favorite: 1,
equation: '1+1',
random: {},
arr: []
});
/* {
hello: "'world'",
favorite: 1,
equation: "'1+1'",
random: "{}",
arr: "[]"
} */
```
#### With `webpack.DefinePlugin`
```js
var webpack = require('webpack');
var stringify = require('stringify-object-values');
module.exports = {
plugins: [
new webpack.DefinePlugin({ 'process.env': stringify(process.env) });
]
}
```