Shopify / sprockets-commoner

Use Babel in Sprockets to compile JavaScript modules for the browser
MIT License
182 stars 22 forks source link

Add extra_options parameter to Processor #32

Closed bouk closed 8 years ago

bouk commented 8 years ago

This PR adds an extra_options (other name proposals welcome) argument to processor, making it possible to configure any path to use a certain set of commoner options, instead of the brittle and not very useful babelrc way of configuring. This also removes configuring commoner in babelrc (this option was hacky and undocumented).

You can now set the globals map using something like the following:

Sprockets::Commoner::Processor.configure(@env, extra_options: {
  'app/assets/javascripts/node_modules' => {
    globals: {
      'jquery' => '$'
    }
  }
})

This will now also affect everything inside node_modules.

@lemonmade @GoodForOneFare

lemonmade commented 8 years ago

Looks great 👍 always bugged me that the configuration was split between different places, this is much better.

rafaelfranca commented 8 years ago

:+1:

GoodForOneFare commented 8 years ago

LGTM 👍

Tried this out yesterday on shopify/shopify, and I was able to get jQuery split into its own bundle. Thanks for your help with configuration!