1

I need to "export" jQuery library from webpack builded bundle.js file to use it in inline scripts on page (eg Google Tag Manager. A Marketer adds different scripts in it with jquery).

I don't want to add jQuery as external library on page. I installed it with npm, import it in webpack and add in webpack.ProvidePlugin. But I still can use $, jQuery or window.jQuery only inside my bundle.js

sqlnoob
  • 119
  • 1
  • 9
  • https://stackoverflow.com/questions/29080148/expose-jquery-to-real-window-object-with-webpack?rq=1 might help you here – Mekicha Aug 11 '17 at 12:10

1 Answers1

0

Just put it into window object, somewhere at the top of your entry point file, before all code which require $, jQuery variable to be present

window.$ = window.jQuery = require('jquery');

P.S. Provide plugin will not work in this case, library won't be available for inline scripts

Andrii Muzalevskyi
  • 3,261
  • 16
  • 20