This summary serves to combine the insights from two valuable answers:
Answer 1, Answer 2
It's important to note that jquery-ui-dist
and jquery-ui-bundle
are not actively maintained by the jquery-ui team, so it's advisable to steer clear of them. However, starting from jquery-ui version 1.11, you can utilize AMD for require/import, and from version 1.12, you have the option to use the official package via npm.
Solution 1 :
The recommended approach is to import specific parts of jquery-ui like this:
import 'jquery-ui/ui/widgets/draggable';
An alternative is having to individually import modules you require, instead of using import 'jquery-ui'
, which will only bundle the necessary imports.
Refer to the 1.11 AMD support documentation and 1.12 npm documentation on their website for more details.
Solution 2 :
For those who prefer a single global import of jquery-ui, adjustments to the webpack configuration are required:
Firstly, ensure webpack recognizes the jquery aliases:
...
plugins: [
new webpack.ProvidePlugin({
'$':'jquery',
'jQuery':'jquery',
'window.jQuery':'jquery',
'global.jQuery': 'jquery'
}),
...
Then assist webpack in resolving the location of the jquery-ui JS file:
resolve : {
alias: {
"jquery-ui": "jquery-ui/jquery-ui.js",
modules: path.join(__dirname, "node_modules"),
Additionally, make sure jquery-ui is loaded early on, perhaps during startup:
var $ = require("jquery"),
require("jquery-ui");
If utilizing a jquery-ui theme, configure the css-loader and file-loader accordingly (and don't forget to install these loaders):
module: {
loaders: [
{ test: /\.css$/, loader: "style!css" },
{ test: /\.(jpe?g|png|gif)$/i, loader:"file" },
Finally, after your imports of jquery and jquery-ui, remember to include:
import 'modules/jquery-ui/themes/black-tie/jquery-ui.css';
import 'modules/jquery-ui/themes/black-tie/jquery-ui.theme.css';