How to require tether with webpack?

2019-09-15 18:39发布

I have a webpack application I'm using with laravel elixir. In this application I have a bootstrap.js file for initializing all of my libraries. Here it is:

window._ = require('lodash');

/**
 * We'll load jQuery and the Bootstrap jQuery plugin which provides support
 * for JavaScript based Bootstrap features such as modals and tabs. This
 * code may be modified to fit the specific needs of your application.
 */

window.$ = window.jQuery = require('jquery');// $ui = require("jquery-ui");
/**
 * import twitter bootstrap js library
 */
require('bootstrap-sass');
/**
 * import jquery ui
 */
require('jquery-ui-bundle');

/**
 * import jquery datatables
 */
require('datatables.net');

/**
 * import select2
 */
require('select2'); // globally assign select2 fn to $ element

/**
 * import d3
 */
require('d3');

/**
 dropdowns
 */
require('tether');
require('tether-drop');

The only issue is, when I go to build this, I get Error: Can't resolve 'tether-drop'. How can I fix this?

Thanks!

1条回答
▲ chillily
2楼-- · 2019-09-15 19:05

To use tether, you'll need to make it available on window.

global.Tether = require('tether');

Now, you can use it with another libraries, for examples, with bootstrap@4. Don't use import.

require('bootstrap');
查看更多
登录 后发表回答