hughsk / hughsk/envify

It's not working

Open
#56 5 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
895
Forks
57
PR merge metrics
No merged PRs in 30d

Description

I'm using Browserify, and when I minified JS code with using React and Redux, it saids:

```bash
Warning: It looks like you're using a minified copy of the development build of React. When deploying React apps to production, make sure to use the production build which skips development warnings and is faster. See https://fb.me/react-minification for more details.

You are currently using minified code outside of NODE_ENV === 'production'. This means that you are running a slower development build of Redux. You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify or DefinePlugin for webpack (http://stackoverflow.com/questions/30030031) to ensure you have the correct code for your production build.
```

So I added envify and used like this:

```javascript
const vendors = [
'connected-react-router',
'history',
'immutable',
'isomorphic-fetch',
'moment',
'react',
'react-dom',
'react-if',
'react-motion-ui-pack',
'react-redux',
'react-router',
'redux'
];
const isProduction = config.isProduction;

function buildVendor() {
const b = persistify({ debug: !isProduction });

vendors.forEach(vendor => {
b.require(vendor);
});

if(isProduction) {
console.log('envify');
b.transform(envify({
NODE_ENV: 'production'
}));
}

let stream = b.bundle()
.on('error', swallowError)
.pipe(source('vendor.js'))
.pipe(buffer())
.pipe(rename('vendor.js'));

if(isProduction) {
stream.pipe(uglify());
}

return stream.pipe(gulp.dest(`${DIST}/js`));
}
```

You can see that when it's production mode, it calls envify, also I printed "envify" on the console when it runs.

After run the browserify(with gulp), it saids 'envify':

```bash
[ec2-user@ip-172-31-22-2 modernator-2]$ gulp build --all
[11:58:05] Using gulpfile ~/modernator-2/gulpfile.js
[11:58:05] Starting 'build'...
envify <-- ENVIFY CALLED
[11:58:05] Moving external resources done. (Time elapsed 27ms.)
[11:58:05] Building HTML done. (Time elapsed 431ms.)
[11:58:05] Compiling SCSS done. (Time elapsed 99ms.)
[11:58:06] 826520 bytes written (1.12 seconds)
[11:58:16] Moving images done. (Time elapsed 11007ms.)
[11:58:16] Finished 'build' after 11 s
```

But still same errors on the webbrowser's console:

```bash
Warning: It looks like you're using a minified copy of the development build of React. When deploying React apps to production, make sure to use the production build which skips development warnings and is faster. See https://fb.me/react-minification for more details.

You are currently using minified code outside of NODE_ENV === 'production'. This means that you are running a slower development build of Redux. You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify or DefinePlugin for webpack (http://stackoverflow.com/questions/30030031) to ensure you have the correct code for your production build.
```

I'm running multiple node services on single server, so I can't set NODE_ENV to production, because some of them are still in development mode. Is there a something that I missed? Why it won't worked at all?

I'm using
- node v.6.9.5
- envify v4.0.0
- browserify v7.3.0

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.