Skip to content

Commit

Permalink
replace application.js sprockets output with webpack-generated equiva…
Browse files Browse the repository at this point in the history
…lent
  • Loading branch information
mikegreiling committed Jan 6, 2017
1 parent 31bd368 commit 55f291e
Show file tree
Hide file tree
Showing 13 changed files with 2,797 additions and 22 deletions.
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
/*= require jquery.endless-scroll */
/*= require jquery.highlight */
/*= require jquery.waitforimages */
/*= require jquery.caret */
/*= require jquery.atwho */
/*= require jquery.scrollTo */
/*= require jquery.turbolinks */
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/lib/utils/datetime_utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
w.gl.utils.days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];

w.gl.utils.formatDate = function(datetime) {
return dateFormat(datetime, 'mmm d, yyyy h:MMtt Z');
return (new Date(datetime)).format('mmm d, yyyy h:MMtt Z');
};

w.gl.utils.getDayName = function(date) {
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/users/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
date.setDate(date.getDate() + i);

var day = date.getDay();
var count = timestamps[dateFormat(date, 'yyyy-mm-dd')];
var count = timestamps[date.format('yyyy-mm-dd')];

// Create a new group array if this is the first day of the week
// or if is first object
Expand Down Expand Up @@ -122,7 +122,7 @@
if (stamp.count > 0) {
contribText = stamp.count + " contribution" + (stamp.count > 1 ? 's' : '');
}
dateText = dateFormat(date, 'mmm d, yyyy');
dateText = date.format('mmm d, yyyy');
return contribText + "<br />" + (gl.utils.getDayName(date)) + " " + dateText;
};
})(this)).attr('class', 'user-contrib-cell js-tooltip').attr('fill', (function(_this) {
Expand Down
293 changes: 293 additions & 0 deletions app/assets/javascripts/webpack/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,293 @@
/* eslint-disable */

/**
* Simulate sprockets compile order of application.js through CommonJS require statements
*
* Currently exports everything appropriate to window until the scripts that rely on this behavior
* can be refactored.
*
* Test the output from this against sprockets output and it should be almost identical apart from
* webpack's CommonJS wrapper. You can add the following line to webpack.config.js to fix the
* script indentation:
* config.output.sourcePrefix = '';
*/

/*= require jquery2 */
window.jQuery = window.$ = require('jquery');

/*= require jquery-ui/autocomplete */
// depends on jquery-ui/core, jquery-ui/widget, jquery-ui/menu, jquery-ui/position
require('jquery-ui/ui/core');
require('jquery-ui/ui/widget');
require('jquery-ui/ui/position');
require('jquery-ui/ui/menu');
require('jquery-ui/ui/autocomplete');

/*= require jquery-ui/datepicker */
// depends on jquery-ui/core
require('jquery-ui/ui/datepicker');

/*= require jquery-ui/draggable */
// depends on jquery-ui/core, jquery-ui/widget, jquery-ui/mouse
require('jquery-ui/ui/mouse');
require('jquery-ui/ui/draggable');

/*= require jquery-ui/effect-highlight */
// depends on jquery-ui/effect
require('jquery-ui/ui/effect');
require('jquery-ui/ui/effect-highlight');

/*= require jquery-ui/sortable */
// depends on jquery-ui/core, jquery-ui/widget, jquery-ui/mouse
require('jquery-ui/ui/sortable');

/*= require jquery_ujs */
require('jquery-ujs');

/*= require jquery.endless-scroll */
require('vendor/jquery.endless-scroll');

/*= require jquery.highlight */
require('vendor/jquery.highlight');

/*= require jquery.waitforimages */
require('vendor/jquery.waitforimages');

/*= require jquery.atwho */
require('vendor/jquery.caret'); // required by jquery.atwho
require('vendor/jquery.atwho');

/*= require jquery.scrollTo */
require('vendor/jquery.scrollTo');

/*= require jquery.turbolinks */
require('vendor/jquery.turbolinks');

/*= require js.cookie */
window.Cookies = require('vendor/js.cookie');

/*= require turbolinks */
require('vendor/turbolinks');

/*= require autosave */
require('../autosave');

/*= require bootstrap/affix */
require('bootstrap/js/affix');

/*= require bootstrap/alert */
require('bootstrap/js/alert');

/*= require bootstrap/button */
require('bootstrap/js/button');

/*= require bootstrap/collapse */
require('bootstrap/js/collapse');

/*= require bootstrap/dropdown */
require('bootstrap/js/dropdown');

/*= require bootstrap/modal */
require('bootstrap/js/modal');

/*= require bootstrap/scrollspy */
require('bootstrap/js/scrollspy');

/*= require bootstrap/tab */
require('bootstrap/js/tab');

/*= require bootstrap/transition */
require('bootstrap/js/transition');

/*= require bootstrap/tooltip */
require('bootstrap/js/tooltip');

/*= require bootstrap/popover */
require('bootstrap/js/popover');

/*= require select2 */
require('select2/select2.js');

/*= require underscore */
window._ = require('underscore');

/*= require dropzone */
window.Dropzone = require('dropzone');

/*= require mousetrap */
require('mousetrap');

/*= require mousetrap/pause */
require('mousetrap/plugins/pause/mousetrap-pause');

/*= require shortcuts */
require('../shortcuts');

/*= require shortcuts_navigation */
require('../shortcuts_navigation');

/*= require shortcuts_dashboard_navigation */
require('../shortcuts_dashboard_navigation');

/*= require shortcuts_issuable */
require('../shortcuts_issuable');

/*= require shortcuts_network */
require('../shortcuts_network');

/*= require jquery.nicescroll */
require('vendor/jquery.nicescroll');

/*= require date.format */
require('vendor/date.format');

/*= require_directory ./behaviors */
require('vendor/jquery.ba-resize');
window.autosize = require('vendor/autosize');
require('../behaviors/autosize'); // requires vendor/jquery.ba-resize and vendor/autosize
require('../behaviors/details_behavior');
require('../extensions/jquery');
require('../behaviors/quick_submit'); // requires extensions/jquery
require('../behaviors/requires_input');
require('../behaviors/toggler_behavior');

/*= require_directory ./blob */
require('../blob/template_selector');
require('../blob/blob_ci_yaml'); // requires template_selector
require('../blob/blob_file_dropzone');
require('../blob/blob_gitignore_selector');
require('../blob/blob_gitignore_selectors');
require('../blob/blob_license_selector');
require('../blob/blob_license_selectors');

/*= require_directory ./templates */
require('../templates/issuable_template_selector');
require('../templates/issuable_template_selectors');

/*= require_directory ./commit */
require('../commit/file');
require('../commit/image_file');

/*= require_directory ./extensions */
require('../extensions/array');
require('../extensions/element');

/*= require_directory ./lib/utils */
require('../lib/utils/animate');
require('../lib/utils/common_utils');
require('../lib/utils/datetime_utility');
// require('../lib/utils/emoji_aliases.js.erb');
window.gl.emojiAliases = function() { return require('emoji-aliases'); };
require('../lib/utils/jquery.timeago');
require('../lib/utils/notify');
require('../lib/utils/text_utility');
require('../lib/utils/type_utility');
require('../lib/utils/url_utility');

/*= require_directory ./u2f */
require('../u2f/authenticate');
require('../u2f/error');
require('../u2f/register');
require('../u2f/util');

/*= require_directory . */
require('../abuse_reports');
require('../activities');
require('../admin');
require('../api');
require('../aside');
require('../awards_handler');
require('../breakpoints');
require('../broadcast_message');
require('../build');
require('../build_artifacts');
require('../build_variables');
require('../commit');
require('../commits');
require('../compare');
require('../compare_autocomplete');
require('../confirm_danger_modal');
window.Clipboard = require('vendor/clipboard'); // required by copy_to_clipboard
require('../copy_to_clipboard');
require('../create_label');
require('vue'); // required by cycle_analytics
require('../cycle_analytics');
require('../diff');
require('../dispatcher');
require('../preview_markdown');
require('../dropzone_input');
require('../due_date_select');
require('../files_comment_button');
require('../flash');
require('../gfm_auto_complete');
require('../gl_dropdown');
require('../gl_field_errors');
require('../gl_form');
require('../group_avatar');
require('../groups_select');
require('../header');
require('../importer_status');
require('../issuable');
require('../issuable_context');
require('../issuable_form');
require('vendor/task_list'); // required by issue
require('../issue');
require('../issue_status_select');
require('../issues_bulk_assignment');
require('../label_manager');
require('../labels');
require('../labels_select');
require('../layout_nav');
require('../line_highlighter');
require('../logo');
require('../member_expiration_date');
require('../members');
require('../merge_request_tabs');
require('../merge_request');
require('../merge_request_widget');
require('../merged_buttons');
require('../milestone');
require('../milestone_select');
require('../namespace_select');
require('../new_branch_form');
require('../new_commit_form');
require('../notes');
require('../notifications_dropdown');
require('../notifications_form');
require('../pager');
require('../pipelines');
require('../project');
require('../project_avatar');
require('../project_find_file');
require('../project_fork');
require('../project_import');
require('../project_new');
require('../project_select');
require('../project_show');
require('../projects_list');
require('../right_sidebar');
require('../search');
require('../search_autocomplete');
require('../shortcuts_blob');
require('../shortcuts_find_file');
require('../sidebar');
require('../single_file_diff');
require('../snippets_list');
require('../star');
require('../subscription');
require('../subscription_select');
require('../syntax_highlight');
require('../todos');
require('../tree');
require('../user');
require('../user_tabs');
require('../username_validator');
require('../users_select');
require('vendor/latinise'); // required by wikis
require('../wikis');
require('../zen_mode');

/*= require fuzzaldrin-plus */
require('vendor/fuzzaldrin-plus');

require('../application');
4 changes: 0 additions & 4 deletions app/assets/javascripts/webpack/bundle.js

This file was deleted.

11 changes: 0 additions & 11 deletions app/assets/javascripts/webpack/hello_world.js.es6

This file was deleted.

3 changes: 1 addition & 2 deletions app/views/layouts/_head.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
= stylesheet_link_tag "application", media: "all"
= stylesheet_link_tag "print", media: "print"
= javascript_include_tag "application"
= javascript_include_tag *webpack_asset_paths("bundle")
= javascript_include_tag *webpack_asset_paths("application")
- if content_for?(:page_specific_javascripts)
= yield :page_specific_javascripts
Expand Down
20 changes: 18 additions & 2 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var DEV_SERVER_PORT = 3808;
var config = {
context: ROOT_PATH,
entry: {
bundle: './app/assets/javascripts/webpack/bundle.js'
application: './app/assets/javascripts/webpack/application.js'
},

output: {
Expand All @@ -31,6 +31,15 @@ var config = {
test: /\.es6$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
test: /\.(js|es6)$/,
loader: 'imports-loader',
query: 'this=>window'
},
{
test: /\.json$/,
loader: 'json-loader'
}
]
},
Expand All @@ -48,7 +57,14 @@ var config = {
],

resolve: {
extensions: ['', '.js', '.es6', '.js.es6']
extensions: ['', '.js', '.es6', '.js.es6'],
alias: {
'bootstrap/js': 'bootstrap-sass/assets/javascripts/bootstrap',
'emoji-aliases$': path.join(ROOT_PATH, 'fixtures/emojis/aliases.json'),
'vendor': path.join(ROOT_PATH, 'vendor/assets/javascripts'),
'vue$': 'vue/dist/vue.js',
'vue-resource$': 'vue-resource/dist/vue-resource.js'
}
}
}

Expand Down
Loading

0 comments on commit 55f291e

Please sign in to comment.