Expose jQuery to real Window object with Webpack
You need to use the expose-loader.
npm install expose-loader --save-dev
You can either do this when you require it:
require("expose?$!jquery");
or you can do this in your config:
loaders: [
{ test: require.resolve('jquery'), loader: 'expose?jQuery!expose?$' }
]
UPDATE: As of webpack 2, you need to use expose-loader instead of expose:
module: {
rules: [{
test: require.resolve('jquery'),
use: [{
loader: 'expose-loader',
options: '$'
}]
}]
}
Expose multiple different objects on the window with webpack
According to this section of the doc, what you want to achieve is doable by ensuring:
- You module is the entry point
output.library
is falsyoutput.libraryTarget = "window"
Related Topics
Jquery Pass More Parameters into Callback
Replace Multiple Whitespaces with Single Whitespace in JavaScript String
JavaScript Sort Function. Sort by First Then by Second
Node Js Promise.All and Foreach
Why Use Jquery On() Instead of Click()
Jquery - Sticky Header That Shrinks When Scrolling Down
Change the Content of a Div Based on Selection from Dropdown Menu
Get Value of a Custom Attribute
Is There a Best Practice for Generating HTML with JavaScript
Force Page Zoom at 100% with Js
How to Get Last Characters of a String
How to Set a JavaScript Breakpoint from Code in Chrome
Internet Explorer 11 Detection
What Does Angular 2 Hashtags in Template Mean
Removing Page Title and Date When Printing Web Page (With CSS)
How to Change HTML Object Element Data Attribute Value in JavaScript