Laravel Elixir with JQuery and JQuery UI
Asked Answered
K

3

6

I'm unable to get JQuery UI required when using Laravel Elixir with Webpack.

Here is my gulpfile.js, nothing unusual:

const elixir = require('laravel-elixir');

elixir.config.sourcemaps = false;

elixir(mix => {
    mix.sass('app.scss')
       .webpack('app.js');
});

My app.js file is where I'm trying to require both JQuery and JQuery UI. I've tried multiple things but this is where I'm at:

window.$ = window.jQuery = require('jquery');
window.$ = $.extend(require('jquery-ui'));

No matter what I do, I can't seem to get JQuery UI required and working.

Kinetic answered 4/11, 2016 at 15:35 Comment(0)
D
7

Figured it out. jquery-ui, as is built and in npm doesn't contain a dist file. In order to solve this you have to use a file called jquery-ui-bundle. Run the following command npm i -S jquery-ui-bundle.

Then require it after jquery

require('jquery');
require('jquery-ui-bundle');

Hope this saves someone some time, I spent a few hours figuring that out!

Deepseated answered 10/12, 2016 at 21:15 Comment(4)
@JagadeshaNH are you using elixir for that too?Deepseated
where do you put the require??Riley
@Riley to import the modulesDeepseated
Thanks @JakeSylvestre. This saved me a lot of time!!Junto
B
3

npm install jquery-ui-bundle --save

In your bootstrap.js add this:

window.$ = window.jQuery = require('jquery');
window.$ = $.extend(require('jquery-ui-bundle'));

npm run dev

Blase answered 24/6, 2017 at 18:29 Comment(0)
N
1

Three simple steps:

  1. Install npm package: npm i -S jquery-ui-bundle

  2. Import javascript (somewhere after jquery importing): require('jquery-ui-bundle');

  3. Import css styles: node_modules/jquery-ui-bundle/jquery-ui.css
Nonmetallic answered 13/5, 2017 at 13:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.