This answer is just a summary of two useful answers: Answer 1 , Answer 2
First, itβs best to know that the jquery-ui-dist and jquery-ui-bundle commands are not supported by the jquery-ui command. Therefore, you probably want to avoid using it. However, from jquery-ui version 1.11 you can require / import AMD, and from version 1.12 you can use the official package with npm.
Solution 1:
The preferred way is to import the jquery-ui part, for example:
import 'jquery-ui/ui/widgets/draggable';
The only drawback is that if you previously used import 'jquery-ui' , now you need to import all the modules that you want to use specifically. But this is better because it will only bind the import that you really need.
Check the 1.11 AMD support documentation and the 1.12 npm documentation on your site.
Solution 2:
But if for any reason you want to use one global jquery-ui import, you will have to adapt the configuration of your web package:
First, make sure webpack knows about jquery aliases:
... plugins: [ new webpack.ProvidePlugin({ '$':'jquery', 'jQuery':'jquery', 'window.jQuery':'jquery', 'global.jQuery': 'jquery' }), ...
Next, help webpack resolve jquery-ui js location:
resolve : { alias: { // bind version of jquery-ui "jquery-ui": "jquery-ui/jquery-ui.js", // bind to modules; modules: path.join(__dirname, "node_modules"),
Then make sure jquery-ui is loaded as soon as possible (perhaps at startup time?)
var $ = require("jquery"), require("jquery-ui");
If you want to use the theme with jquery-ui, you will have to configure the css loader and file loader accordingly. (Remember to install these bootloaders):
module: { loaders: [ { test: /\.css$/, loader: "style!css" }, { test: /\.(jpe?g|png|gif)$/i, loader:"file" },
And below you import jquery and jquery-ui just add:
import 'modules/jquery-ui/themes/black-tie/jquery-ui.css'; import 'modules/jquery-ui/themes/black-tie/jquery-ui.theme.css';