-
Notifications
You must be signed in to change notification settings - Fork 681
Build JavaScript using Gulp and install some JavaScript libraries with Bower #3041
Conversation
17e1e08
to
9bae013
Compare
@@ -0,0 +1,15 @@ | |||
{ | |||
"name": "MDN", |
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.
Could you name that kuma as that's the name of the software while MDN is the product?
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.
Sure
d54d5a7
to
532f04b
Compare
c9e5b47
to
fc867c7
Compare
fec2e47
to
040b03d
Compare
I was adding commits to this PR yesterday and today, but I'll stop now so that we can review something more stable. This is ready to be reviewed whenever. |
49753a6
to
cb48cc0
Compare
@openjck I'll look tomorrow |
cb48cc0
to
011a974
Compare
On "/en-US/docs/new?slug=Tools", I get this error:
|
011a974
to
c376eee
Compare
Nice catch! Fixed. |
c376eee
to
3fb71ed
Compare
5b4192d
to
7efdfbe
Compare
Definitely an improvement worth making to the codebase. It would be a lot easier to do once all JavaScript and CSS has been migrated to Gulp. How do we feel about postponing until then? |
We could use cloudfare, but it only hosts versions newer than the version we're using. We should upgrade the plugin eventually, but the scope of this pull request is just to move existing requirements to Bower. |
Same with this plugin. GitHub only hosts newer versions of the plugin, and the scope at the moment is just to migrate requirements to Bower. Because the requirements are pulled down locally, we'll have other options if the host goes down, including restoring the plugin source from our Git history. |
1d8a092
to
d99c9cb
Compare
This is looking good to me. I especially like the I was able to rebase pretty easily too. How can I make my local dev vm serve up the un-bundled, non-minified assets? jingo-minify does this with the Maybe some similar helpers on top of the new |
for(var bundleName in jsBundles) { | ||
if(jsBundles.hasOwnProperty(bundleName)) { | ||
var bundle = jsBundles[bundleName]; | ||
watchJSBundle(bundleName, bundle); |
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.
This didn't seem to work for me as I expected. Steps to reproduce:
gulp watch
- Change
analytics.js
(I just added analert("gulp changed me!");
line to it) - Refresh home page
Expected results:
Should see the "gulp changed me!" alert box.
Actual results:
Nothing. 😦
And only this showing on the console:
(env)vagrant@developer-local:~/src$ gulp watch [55/1609]
[21:16:11] Using gulpfile ~/src/gulpfile.js
[21:16:11] Starting 'watch'...
[21:16:11] Finished 'watch' after 83 ms
It wasn't until I did gulp
(to run build-javascript
) that the changes took effect.
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.
Thanks for explaining that. How long was the wait between steps 2 and 3? This sounds like bug 1054257.
There are a few ways around that: we could fix bug 1054257, tell developers to run Gulp on the host machine, or tell developers to wait for a few moments after making file changes. The first option could become a rabbit hole, but one of the others might work in the short term. On the plus side, the delay is no worse than the delay in compiling stylesheets, which we've become used to.
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.
I ran gulp watch
and then went and did some emails for about 20 minutes. 😉 Still no action. 😦
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.
Weird, I can't reproduce. Are you sure media/js/analytics.js
was edited, and not one of the files also named analytics.js
from the Bower package? Was gulp watch
run locally or in the VM?
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.
Yup, media/js/analytics
. Ran gulp watch
in the VM.
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.
Do you have NFS disabled by any chance? I hear that under some conditions (I think disabled NFS is one of them) Vagrant doesn't pick up on file changes.
What happens if you run gulp watch
on the host?
The directory media/js/libs/owl.carousel is not removed because jingo-minify still refers to stylesheets from that directory. The directory can be removed once Gulp is used to build CSS.
The directory media/js/libs/prism is not removed because jingo-minify still refers to stylesheets from that directory. The directory can be removed once Gulp is used to build CSS.
d99c9cb
to
06b1291
Compare
Good question. I never found unbundled assets to be especially helpful, but I can see a case for them if someone really needs to use the debugger with the original symbols. This will take some thought. It will need to be something more expansive than changing |
I find unbundled CSS to be quite helpful and would be sad it it went away. |
My McDonald's idea:
Seem logical? |
@groovecoder -1 on writing our own Python stuff to handle bundles, we should follow the best practices of the community and use django-pipeline. It's what bedrock has been moved to, too. |
👍 using best practices python. That would mean moving the bundle declarations out of |
django-pipeline also does concatenation and minification. Is it worth the effort to get django-pipeline and Gulp to talk to each other if django-pipeline does the same job anyway? |
That's a big question. Let's start a thread with dev-mdn and dev-webdev about it? |
It would be easiest to do this either entirely with a Django plugin or entirely with Gulp. If we do this entirely with Gulp, and we need uncompressed assets locally, we'll need to run Gulp at deploy time to treat different environments differently. |
@openjck Agreed, I don't think we should mix gulp and another tool that does asset compilation, concatenation, minification, etc – that was my point earlier really. I'm happy to use gulp, but we should use it completely and not compromise. Looking back at https://lincolnloop.com/blog/integrating-front-end-tools-your-django-project/ this is what they went with, staticfiles only for the management of Python side static files and gulp for any processing. |
The more testing we can do, the better. This changes a lot of important resources.
Some things to think about:
{{ js() }}
calls been replaced? Aside from the{{ js() }}
calls, is there anything else that needs to be updated?gulp watch
in foreman)?Other notes:
vagrant provision
before reviewing this to get the latest copy of ~/.bash_profile in the VM