Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specify jQuery for bootstrap in webpack

Tags:

webpack

In my project, I want to import Bootstrap, but it depends on jQuery.

require('jquery/dist/jquery.min'); 
require('bootstrap/dist/js/bootstrap.min');

When I use Webpack to handle this project, it causes an error:

Uncaught Error: Bootstrap's JavaScript requires jQuery

How can I specify jQuery for Bootstrap?

like image 352
zq010 Avatar asked Apr 01 '15 03:04

zq010


2 Answers

Replace your require statement with the following:

window.jQuery = window.$ = require('jquery/dist/jquery.min');

like image 138
Антон Брагин Avatar answered Oct 17 '22 01:10

Антон Брагин


require('!!script!jquery/dist/jquery.min.js');

The !!script! is a special flag that will inline the script without using any loaders, equivalent to using a <script> tag in HTML.

like image 43
Varun Mulloli Avatar answered Oct 17 '22 00:10

Varun Mulloli