title: How to make jquery available to sprockets using Webpacker?
body: <p>I've just started experimenting with Webpacker within an existing app. </p>
  
  <p>From all that I've read, my understanding is that Webpacker and Sprockets can co-exist, and that libraries compiled in Webpacker (e.g., jquery) can be made available to Sprokets via global variables. </p>
  
  <p>But all my jquery in the asset pipeline are raising <code>ReferenceError: Can't find variable: $</code></p>
  
  <p>Have I misunderstood, or is there a bug in my code? </p>
  
  <p>I've added jquery </p>
  
  <p><code>yarn add jquery</code></p>
  
  <p>and assigned the variables in environment.js</p>
  
  <pre><code>const { environment } = require('@rails/webpacker');
  
  const webpack = require('webpack');
  environment.plugins.prepend('Provide', new webpack.ProvidePlugin({
      $: 'jquery',
      jQuery: 'jquery'
  }));
  
  module.exports = environment;
  </code></pre>
  
  <p>this works:</p>
  
  <pre><code>#javascript/packs/application.js
  $(function () {
      console.log('Hello World from Webpacker via JQUERY');
  });
  </code></pre>
  
  <p>this does not</p>
  
  <pre><code>#assets/javascripts/application.js
  $(function () {
      console.log('Hello World from Sprockets via JQUERY');
  });
  # ReferenceError: Can't find variable: $
  </code></pre>
  
  <p>What is the expected behaviour? </p>