Implicit imports in Webpack using ProvidePlugin

Do you find yourself writing this in every single one of your files?

import React from ‘react'

Remember how you used the ProvidePlugin to replace Promise globally in your app?

We can use that same approach for stuff we’re using everywhere else too.

// webpack.config.js

new webpack.ProvidePlugin({
  React : ‘react’,
  Promise : ‘bluebird’,
  cx : 'classnames',
  get : 'lodash.get'
})

Now, I understand I use a few examples here, but I wouldn’t get too crazy. Focus on the packages you’re confident you’re going to use EVERYWHERE

  • Avatar for Peter
  • Avatar for Peter
  • Avatar for Peter
  • Avatar for Peter
  • Avatar for Peter