Comments (6)
@ron23 you could use webpack.DefinePlugin
to create a condition that will be allowed to install immutable-devtools
in the debug build but unreachable in the production build.
// webpack.config.js
var webpack = require('webpack');
module.exports = {
// ...
plugins: [
new webpack.DefinePlugin({
__DEV__: JSON.stringify(process.env.NODE_ENV !== 'production')
})
],
};
In your source you'd have something like this...
// index.js
var immutable = require('immutable');
if (__DEV__) {
var installDevTools = require('immutable-devtools');
installDevTools(immutable);
}
When you set NODE_ENV=production
, __DEV__
will be replaced with false
.
NODE_ENV=production webpack index.js dist/index.min.js
generates
var immutable = require('immutable');
if (false) {
var installDevTools = require('immutable-devtools');
installDevTools(immutable);
}
// ...
And then by adding the -p
shortcut to webpack for production mode which enables dead code elimination, the condition that requires immutable-devtools will be removed.
NODE_ENV=production webpack -p index.js
var immutable = require('immutable');
// ...
from immutable-devtools.
Nice! I thought about everything you said but I didn't know the magic -p !!! Thanks a lot!
from immutable-devtools.
@ron23 you're welcome! You can also get dead code elimination by adding the uglifyjs plugin new webpack.optimize.UglifyJsPlugin()
to the plugins
array in your webpack.config.js
if you want to tune your production build.
from immutable-devtools.
Already using it, just didn't know about the dead code removal feature. Thanks a bunch!
from immutable-devtools.
Hi everybody!
This is something that Wiki is interested in :-)
Can anybody write shot paragraph about this in project wiki?
from immutable-devtools.
@ron23 Thanks! I've added section Using with webpack in Readme based on your comment
from immutable-devtools.
Related Issues (20)
- 'install' is undefined, function name appears to have been removed by uglification HOT 3
- installDevTools is not a function HOT 3
- Can this be an extension ? HOT 5
- installDevTools(immutable) returns undefined. HOT 1
- Failing on Chrome Canary builds HOT 12
- Throw away dependency on Immutable HOT 3
- Implement support for Range
- Implement support for Repeat
- Implement support for Seq HOT 4
- Opera Support HOT 1
- Any plan to work in React Native? HOT 5
- Chrome >=48.0 required HOT 6
- Add note to enable custom formatters in docs
- Breaks with Immutable v4 HOT 2
- Not working with DevTools (server side) HOT 3
- Not working in chrome 69 HOT 1
- Typo in renderIterableBody?
- The string "null" is formatted as null
- Cannot show Record with an undefined property HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from immutable-devtools.