aurajs / aura

A scalable, event-driven JavaScript architecture for developing component-based applications.
MIT License
2.94k stars 256 forks source link

Build single js file from widgets sources with r.js #252

Open mbektimirov opened 11 years ago

mbektimirov commented 11 years ago

Is it possible to combine all widgets and templates to a single js file with r.js? Now widgets directory is just copying to dist, but how to do correct concatenation and compression with all widgets?

c4milo commented 11 years ago

I was wondering about the same. I basically need to speed up the first page loaded by the user by minimizing the amout of initial HTTP round-trips. Is there any example about how to do that in Aura?

sbellity commented 11 years ago

Sure it is.

You can have a look at different ways to do it :

https://github.com/sbellity/aura-app-build/blob/master/Gruntfile.js https://github.com/hull/hullagram And cf. #250

Let me know what works best for you...

mbektimirov commented 11 years ago

sbellity/aura-app-build looks good, thanks @sbellity ! By the way, hullagram does not use requirejs so those modules can be simply combined together.

sbellity commented 11 years ago

Hey @mbektimirov, cool ! Actually hullagram does use resuirejs.. It's just hidden in the Hull.widget method ;)

If you are interested, you can have a look at how it's done in hull/hull-js

mbektimirov commented 11 years ago

I could build all my widgets to single file, but now I'm struggling with widgets local components loading. Requirejs is trying to load it from network instead the 'define' definition. For example, I have a widget 'infocard' with main.js and templates by path './widgets/infocard/templates/splash.html'. After compiling I see a lot of errors like this:

GET http://localhost:3000/scripts/widgets/infocard/templates/splash.html 404 (Not Found)

I don't understand why requirejs wants to load this templates and additional scripts through GET request, because they are all compiled in one file.

addyosmani commented 11 years ago

Could you share a smaller version of your project reproducing this issue so we can investigate further? If not can you see if explicitly setting the baseUrl in your source eases the issue at build time?

imrane commented 10 years ago

@mbektimirov I'm having the same problem - were you able to solve this issue?