-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Use Webpack Encore to manage assets #586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
var $ = require('jquery'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about putting the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes ... but let's do that when we switch the entire app to Flex. |
||
window.$ = $; | ||
window.jQuery = $; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You shouldn't need either of these unless we still have some JavaScript code in a template somewhere that is relying on these to be globally available. The only place I could see was There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I remove it, I see this error in any backend page:
|
||
|
||
require('bootstrap-sass'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about a comment above this: // loads the Bootstrap jQuery plugins |
||
require('moment'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't be needed. I think only the |
||
require('eonasdan-bootstrap-datetimepicker'); | ||
|
||
require('imports-loader?define=>false!typeahead.js/dist/typeahead.jquery.min.js'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why using the imports-loader ? The dist files are using UMD, so they should work fine with CommonJS requirements. I think all your issues about defining global variables are actually related to the weird loading you do here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have no idea ... I spent a lot of time trying to make typeahead/bloodhound work. Nothing worked. This was one of the tests that I did after reading some of the issues reported about this library (there are like a lot of issues reported!) |
||
const Bloodhound = require('imports-loader?define=>false!typeahead.js/dist/bloodhound.js'); | ||
window.Bloodhound = Bloodhound; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, this shouldn't be needed (in theory), but it's possible there's some legacy library that isn't requiring this correctly. We'll need to make sure each line is needed, and document which lines are needed and why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I remove those, I see this error:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see a lot of errors related to this library. Maybe we can replace it with some simpler alternative library? After all, our needs are super basic. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We might decide to change: twitter/typeahead.js#1618 |
||
require('bootstrap-tagsinput'); | ||
|
||
$(document).ready(function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be changed to just |
||
// Datetime picker initialization. | ||
// See http://eonasdan.github.io/bootstrap-datetimepicker/ | ||
$('[data-toggle="datetimepicker"]').datetimepicker({ | ||
icons: { | ||
time: 'fa fa-clock-o', | ||
date: 'fa fa-calendar', | ||
up: 'fa fa-chevron-up', | ||
down: 'fa fa-chevron-down', | ||
previous: 'fa fa-chevron-left', | ||
next: 'fa fa-chevron-right', | ||
today: 'fa fa-check-circle-o', | ||
clear: 'fa fa-trash', | ||
close: 'fa fa-remove' | ||
} | ||
}); | ||
|
||
// Bootstrap-tagsinput initialization | ||
// http://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/ | ||
var $input = $('input[data-toggle="tagsinput"]'); | ||
if ($input.length) { | ||
var source = new Bloodhound({ | ||
local: $input.data('tags'), | ||
queryTokenizer: Bloodhound.tokenizers.whitespace, | ||
datumTokenizer: Bloodhound.tokenizers.whitespace | ||
}); | ||
$input.tagsinput({ | ||
trimValue: true, | ||
focusClass: 'focus', | ||
typeahead: { | ||
name: 'tags', | ||
source: source | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
// Handling the modal confirmation message. | ||
$(document).on('submit', 'form[data-confirmation]', function (event) { | ||
var $form = $(this), | ||
$confirm = $('#confirmationModal'); | ||
|
||
if ($confirm.data('result') !== 'yes') { | ||
//cancel submit event | ||
event.preventDefault(); | ||
|
||
$confirm | ||
.off('click', '#btnYes') | ||
.on('click', '#btnYes', function () { | ||
$confirm.data('result', 'yes'); | ||
$form.find('input[type="submit"]').attr('disabled', 'disabled'); | ||
$form.submit(); | ||
}) | ||
.modal('show'); | ||
} | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
var $ = require('jquery'); | ||
window.$ = $; | ||
window.jQuery = $; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be able to remove lines 2 and 3 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I remove them, I see this error:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. then it means that the typeahead plugin does not support getting jQuery through CommonJS |
||
|
||
require('bootstrap-sass/assets/javascripts/bootstrap/dropdown.js'); | ||
require('bootstrap-sass/assets/javascripts/bootstrap/modal.js'); | ||
require('bootstrap-sass/assets/javascripts/bootstrap/transition.js'); | ||
|
||
var hljs = require('highlight.js'); | ||
hljs.registerLanguage('php', require('highlight.js/lib/languages/php')); | ||
hljs.registerLanguage('twig', require('highlight.js/lib/languages/twig')); | ||
window.hljs = hljs; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't be needed |
||
hljs.initHighlightingOnLoad(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this need to be in a document.ready? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
@import "~bootswatch/flatly/variables"; | ||
@import "~eonasdan-bootstrap-datetimepicker/src/sass/bootstrap-datetimepicker-build.scss"; | ||
@import "~bootstrap-tagsinput/src/bootstrap-tagsinput.css"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When a CSS file is a dependency of some JS library, I usually like to require the CSS file right in our |
||
|
||
/* Page: 'Backend post index' | ||
------------------------------------------------------------------------- */ | ||
body#admin_post_index .item-actions { | ||
white-space: nowrap | ||
} | ||
|
||
body#admin_post_index .item-actions a.btn + a.btn { | ||
margin-left: 4px | ||
} | ||
|
||
/* Page: 'Backend post show' | ||
------------------------------------------------------------------------- */ | ||
body#admin_post_show .post-tags .label-default { | ||
background-color: #e9ecec; | ||
color: #6D8283; | ||
font-size: 16px; | ||
margin-right: 10px; | ||
padding: .4em 1em .5em; | ||
} | ||
body#admin_post_show .post-tags .label-default i { | ||
color: #95A6A7; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this rule about ? AFAIK, it does not do anything, as the folder is not excluded before (
/build/
does not match it AFAIK, unlikebuild/
would do)