-
-
Notifications
You must be signed in to change notification settings - Fork 79.1k
Util is not defined when referencing individual jQuery plugins (modal.js) via webpack #20709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thank you. |
@mdcuesta try this |
I get the same error when enqueueing singular JS files (dropdown and collapse) in WordPress or including those files via a gulp process. Enqueueing the bootstrap-min.js file doesn't throw those errors, however. |
@gilbarbara any idea how to do that with update: shakacode/bootstrap-loader#172 |
@edouard-lopez |
Here is how I did it: Installed
Import the
Map
For referenceI'm working with:
|
I find that code in 'bootstrap/js/src/util.js' was written in ES6 style:
So, instead of importing files under 'bootstrap/js/dist', you should import them from 'bootstrap/js/src'
In the entry file:
|
Thank you very much @Vivi-wu . It worked for me. |
@Vivi-wu Thanks, this is the solution. I'd like to add that you need support for the spread operator, and that can be achieved with "babel-preset-stage-2". In addition, the path to bootstrap may need to be a part of the include property in webpack.config, e.g.
|
For anybody using laravel-mix, something along the following needs to be added to your Mix.listen('configReady', ({ module }) => {
module.rules.find(rule => {
if (rule.test.test && rule.test.test('test.js')) {
delete rule.exclude;
rule.include = [
__dirname + '/resources/assets/js/',
__dirname + '/node_modules/bootstrap/js/',
];
}
});
}); |
@Vivi-wu hi, I tried your solution but I still have a "Util is not defined" when I try to launch my modal. Would you mind to take a look at this issue that I created yesterday about eveything I've done to make it work? Thank you for your time. |
I got an error Uncaught ReferenceError: Util is not defined when referencing plugins individually.
// jQuery defined global
import '.../....../util.js;
import '.../...../modal.js
The rest is HTML.
Note that referencing the bootstrap.js directly works
// jQuery defined global
import '.../....../bootstrap.js;
The text was updated successfully, but these errors were encountered: