Commit 7371f6cd authored by Mike Greiling's avatar Mike Greiling

refactor common bundle to ES module syntax and move global exports to application.js

parent cb6c036d
...@@ -6,14 +6,29 @@ ...@@ -6,14 +6,29 @@
/* global AwardsHandler */ /* global AwardsHandler */
/* global Aside */ /* global Aside */
// common libraries import jQuery from 'jquery';
window.Cookies = require('js-cookie'); import _ from 'underscore';
window.Pikaday = require('pikaday'); import Cookies from 'js-cookie';
window._ = require('underscore'); import Pikaday from 'pikaday';
window.Dropzone = require('dropzone'); import Dropzone from 'dropzone';
window.Sortable = require('vendor/Sortable'); import Sortable from 'vendor/Sortable';
// libraries with import side-effects
require('mousetrap'); require('mousetrap');
require('mousetrap/plugins/pause/mousetrap-pause'); require('mousetrap/plugins/pause/mousetrap-pause');
require('vendor/fuzzaldrin-plus');
require('es6-promise').polyfill();
// expose common libraries as globals (TODO: remove these)
window.jQuery = jQuery;
window.$ = jQuery;
window._ = _;
window.Cookies = Cookies;
window.Pikaday = Pikaday;
window.Dropzone = Dropzone;
window.Sortable = Sortable;
// shortcuts
require('./shortcuts'); require('./shortcuts');
require('./shortcuts_navigation'); require('./shortcuts_navigation');
require('./shortcuts_dashboard_navigation'); require('./shortcuts_dashboard_navigation');
...@@ -189,9 +204,6 @@ require('./visibility_select'); ...@@ -189,9 +204,6 @@ require('./visibility_select');
require('./wikis'); require('./wikis');
require('./zen_mode'); require('./zen_mode');
require('vendor/fuzzaldrin-plus');
require('es6-promise').polyfill();
(function () { (function () {
document.addEventListener('beforeunload', function () { document.addEventListener('beforeunload', function () {
// Unbind scroll events // Unbind scroll events
...@@ -269,7 +281,7 @@ require('es6-promise').polyfill(); ...@@ -269,7 +281,7 @@ require('es6-promise').polyfill();
$.fn.tooltip.Constructor.DEFAULTS.trigger = 'hover'; $.fn.tooltip.Constructor.DEFAULTS.trigger = 'hover';
$body.tooltip({ $body.tooltip({
selector: '.has-tooltip, [data-toggle="tooltip"]', selector: '.has-tooltip, [data-toggle="tooltip"]',
placement: function (_, el) { placement: function (tip, el) {
return $(el).data('placement') || 'bottom'; return $(el).data('placement') || 'bottom';
} }
}); });
......
require('./jquery'); import 'jquery';
// twitter bootstrap plugins // bootstrap jQuery plugins
require('bootstrap-sass/assets/javascripts/bootstrap/affix'); import 'bootstrap-sass/assets/javascripts/bootstrap/affix';
require('bootstrap-sass/assets/javascripts/bootstrap/alert'); import 'bootstrap-sass/assets/javascripts/bootstrap/alert';
require('bootstrap-sass/assets/javascripts/bootstrap/dropdown'); import 'bootstrap-sass/assets/javascripts/bootstrap/dropdown';
require('bootstrap-sass/assets/javascripts/bootstrap/modal'); import 'bootstrap-sass/assets/javascripts/bootstrap/modal';
require('bootstrap-sass/assets/javascripts/bootstrap/tab'); import 'bootstrap-sass/assets/javascripts/bootstrap/tab';
require('bootstrap-sass/assets/javascripts/bootstrap/transition'); import 'bootstrap-sass/assets/javascripts/bootstrap/transition';
require('bootstrap-sass/assets/javascripts/bootstrap/tooltip'); import 'bootstrap-sass/assets/javascripts/bootstrap/tooltip';
require('./jquery'); import './jquery';
require('./bootstrap'); import './bootstrap';
// jQuery library import 'jquery';
window.$ = window.jQuery = require('jquery');
// jQuery plugins // common jQuery plugins
require('jquery-ujs'); import 'jquery-ujs';
require('vendor/jquery.endless-scroll'); import 'vendor/jquery.endless-scroll';
require('vendor/jquery.caret'); import 'vendor/jquery.caret';
require('vendor/jquery.atwho'); import 'vendor/jquery.atwho';
require('vendor/jquery.scrollTo'); import 'vendor/jquery.scrollTo';
require('vendor/jquery.nicescroll'); import 'vendor/jquery.nicescroll';
require('vendor/jquery.waitforimages'); import 'vendor/jquery.waitforimages';
require('select2/select2.js'); import 'select2/select2';
...@@ -87,6 +87,12 @@ var config = { ...@@ -87,6 +87,12 @@ var config = {
// prevent pikaday from including moment.js // prevent pikaday from including moment.js
new webpack.IgnorePlugin(/moment/, /pikaday/), new webpack.IgnorePlugin(/moment/, /pikaday/),
// fix legacy jQuery plugins which depend on globals
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
}),
// use deterministic module ids in all environments // use deterministic module ids in all environments
IS_PRODUCTION ? IS_PRODUCTION ?
new webpack.HashedModuleIdsPlugin() : new webpack.HashedModuleIdsPlugin() :
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment