How to require tether with webpack?

拥有回忆 提交于 2019-12-12 03:54:19

问题


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:


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');


来源:https://stackoverflow.com/questions/41135593/how-to-require-tether-with-webpack

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!