wearethoughtfox / amnesty-facebook

0 stars 0 forks source link

Smush and minify CSS and JS files #34

Closed robertocarroll closed 7 years ago

robertocarroll commented 7 years ago

Can you see a way to get https://github.com/mishoo/UglifyJS2 to work with nested folders?

robertocarroll commented 7 years ago

Related to #41

robertocarroll commented 7 years ago

I added a build process for the javascript files: https://github.com/wearethoughtfox/amnesty-facebook/commit/d1165a21982ee5b56667661316b855e44f1d995d

It's very manual because even though you can specify folders with globs the only way to preserve the order seems to be to specify each file in the order you need it.

The alternative, I suppose, is something like browserify (back to the start!). Let me know what you think.

robertocarroll commented 7 years ago

Thinking of giving Browserify and Gulp another go. Reading about it here: https://ponyfoo.com/articles/a-gentle-browserify-walkthrough

Two main issues with current approach:

  1. It is indeed troublesome to manage the order of minifying using uglify
  2. How to copy the templates from index to index (can't just copy the file because the CSS and JS references are different).

The aim would be to create a solid build process. Anyway, let me know what you think.

robertocarroll commented 7 years ago

This person has done most of the work:

The bit I'm not clear about is what needs "requiring" in each file. Obviously that's how you manage the dependencies rather than the source order of the loading js files, but let's say "app.js" requires backbone and marionette and jQuery, they still require Marionette in the view - is that because Marionette is directly referenced in the extend?

https://www.sitepoint.com/getting-started-browserify/

robertocarroll commented 7 years ago

So I think I'm clear about the process here:

I'll give this a go in a branch and see what happens (not tonight though ;) )

robertocarroll commented 7 years ago

I think it's fair to say I failed with Browserify (again), so the build process is pretty manual and brittle. Closing until we see where the client takes it next.