Step 1: Install Dependencies

First, install jquery and jquery-ui via npm:

bash

Copy code

npm install jquery jquery-ui

Step 2: Configure Webpack

If you’re using Webpack, you need to ensure that jQuery is globally available because jQuery UI depends on it.

const path = require('path');
const webpack = require('webpack');

module.exports = {
    entry: './src/index.js', // Adjust this to your entry file
    output: {
        filename: 'bundle.js',
        path: path.resolve(__dirname, 'dist')
    },
    module: {
        rules: [
            {
                test: /\.css$/,
                use: ['style-loader', 'css-loader']
            }
        ]
    },
    plugins: [
        new webpack.ProvidePlugin({
            $: 'jquery',
            jQuery: 'jquery'
        })
    ],
    resolve: {
        alias: {
            jquery: "jquery/src/jquery"
        }
    }
};
3. Import jQuery and jQuery UI in your JavaScript file: In your entry file (e.g., src/index.js), you can import jQuery and jQuery UI:

window.$ = $;
window.jQuery = $;
import $ from 'jquery';
import 'jquery-ui/ui/widgets/autocomplete'; // Import specific widget

// Import the jQuery UI CSS
import 'jquery-ui/themes/base/all.css';

// Your custom JS code
$(document).ready(function() {
    $('#search-input').autocomplete({
        source: ['Option 1', 'Option 2', 'Option 3']
    });
});

4.Add jQuery UI CSS
To include jQuery UI's CSS, you can either:

Use the import statement as shown in the above example.

 
@import 'jquery-ui/themes/base/all.css';
@import 'jquery-ui/themes/base/core.css';
@import 'jquery-ui/themes/base/theme.css';
@import 'jquery-ui/themes/base/autocomplete.css'; // Import specific widget CSS

By toihid