I try =>
import BootstrapDateTimePicker from "eonasdan-bootstrap-datetimepicker"; and console.log(BootstrapDateTimePicker);
And console.log return me empty object.
I try =>
import from "eonasdan-bootstrap-datetimepicker";
But i have Uncaught TypeError: $(".picker").datetimepicker is not a function
Please add module.exports = $.fn.datetimepicker;
to 2551 line
I have no idea what you're talking about.
Hi, look, I met the same problem. That's what he tried to say.
He tried to import your plugin via require, but he gets empty object, when he did.
So he asks you to add module.exports
Regards!
I don't know anything about require or webpacks. You're welcome to put in a pull request
Well, I did pull-request which solves this problem. Hope you'll accept it ASAP.
Thanks in advance!
@alxrm Could you link to the PR or state if it is already merged?
@alxrm Thanks. It looks like it wasn't merged but rejected.
Did you get this date picker to properly working with webpack?
I ran into the same problem, and managed to solve/(hack around) it as follow:
node_modules/eonasdan-bootstrap-datetimepicker/src/js/bootstrap-datetimepicker.js
node_modules/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.css
Under plugins, add:
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'windows.jQuery': 'jquery'
})
Under resolve, add:
modulesDirectories: ['custom_modules', 'node_modules'],
alias: {
'datetimepicker': 'eonasdan-bootstrap-datetimepicker/bootstrap-datetimepicker.js'
}
import 'datetimepicker';
import 'style!css!eonasdan-bootstrap-datetimepicker/bootstrap-datetimepicker.css';
I ran into the same problem too. Datetimepicker tries to load its own jQuery.
So the solution is very simple:
resolve: {
alias: {
'jquery': path.join(__dirname, 'node_modules/jquery/dist/jquery'),
}
}
@aburkut Thank you. I've been pulling my hair out for about 24 hours and that little alias fixes everything. My webpack.config.js:
var path = require('path');
module.exports = {
resolve: {
alias: {
// Force all modules to use the same jquery version.
'jquery': path.join(__dirname, 'node_modules/jquery/src/jquery')
}
}
};
Man, I've been looking for this solution for the past few hours. None of the plugins (datetimepicker, popover, tooltips) wanted to work and I always got a Uncaught TypeError: $(…).datetimepicker is not a function-like error. Had to be Webpack messing things up.
THANK YOU @aburkut
Is there an example on usage of this plugin with webpack?
@kebian If I could like your post 1000+ times, I would've done so!
Thank you
Most helpful comment
@aburkut Thank you. I've been pulling my hair out for about 24 hours and that little alias fixes everything. My webpack.config.js: