simison / bootstrap3-less

(deprecated) Bootstrap 3 for Meteor, with Less.
60 stars 19 forks source link

idea: cleaner way for modular inclusion #19

Open Nemo64 opened 10 years ago

Nemo64 commented 10 years ago

Ok, this is more an idea so i want to discuss it.

Currently it is possible to load only less files that one needs in a project, which is awesome. But there are still all javascript files loaded. Most of my tiny projects do not need any of them.

My Idea is it to (ab)use meteors source handler to modify a bootstrap.json. This file would look like this:

{
  "variables": "client/variables.less" // modified variables file (optional)

  "scaffolding": true, // include scaffording.less
  "type": true, // include type.less
  // ...
  "modals": true // include modals.less as well as modals.js
  // ...
}

Not only would it reduce the clutter of the current bootstrap.less (it's cleaner) but it would allow to include js only when nessesary though compileStep.addJavaScript. I would create the less file then dynamically and add it with compileStep.addAsset.

This could also be sort of backwards compatible because the bootstrap.less of project that already use this package would still work. I currently don't know if it would be possible to include the javascript if no bootstrap.json is found.

Any thoughts?

simison commented 10 years ago

Hmm, yeah, there definitely is big need for conditional js loading. I've been kinda hoping smart packages would actually become smart towards 1.0 but no news about that yet.

Would be very good to get everything loading if no bootstrap.json. Maybe it's possible to write npm helper inside the package to check if file exists?

Does this compiling result with new files to package's folder? If so, it needs to make difference between different apps using the same package in localhost.

I'll try to understand more this on better time, feel free to offer some examples in a separate branch.

Great! :+1:

simison commented 10 years ago

BTW I think ngMeteor (Angular) project has some kind of meta-packages system built, there could be some interesting examples in their code.

Nemo64 commented 10 years ago

I'm currently working on it. (fork ;))

Btw. was there any reason to rename the bootstrap files? Files in a package only get imported when they are mentioned in the package.js which they aren't. It would be cleaner if bootstrap would be a sub repository. I guess it's to late for that. It would break everything to do that now!

simison commented 10 years ago

Files were called .lessimport before so meteor would've stopped treating them as less files eventually. No problem if they would've been just .less in first place.

Well, now they're .import.less then. :-)

simison commented 10 years ago

https://trello.com/c/mHK2dpr5/68-new-way-of-defining-packages-and-controlling-file-load-order

Nemo64 commented 10 years ago

OK, this is my try! I haven't fixed the issue with loading the javascript if no json file is present yet though.

Nemo64 commented 10 years ago

oopps, i wanted to cancel the comment, not close the issue :D