Trim Agency
Posted on January 29, 2017 by Dom Miller on Team Trim, Today I Learned

Environment Variables in Webpack

Diving into webpack module loader can often seem like a confusing and daunting task. Luckily, setting environment variables is rather straight forward. At the top of your webpack.config.js file define your environment variables like so: Then in the plugins array use DefinePlugin method to define global variables configured at compile time: Re-compile and now your […]

Posted on January 21, 2017 by Dom Miller on Today I Learned

Immutable Objects using Object.assign

Is immutability important? Mutating data can produce code that’s hard to read and error prone. But we can avoid this mess using vanilla javascript’s ES6 feature Object.assign! Let’s look at the problem…. When we changed obj2’s key property, it also changed obj1’s key property. No bueno! The solution: As you can see we changed obj2’s […]