Giter VIP home page Giter VIP logo

Comments (4)

sheerun avatar sheerun commented on June 16, 2024

It's not agreed upon, but I think foundation gets it right:

  1. Separate distribution repository, so you don't need to put compiled files in source repo, and packaged .zip by github doesn't contain unnecessary files, like docs.
  2. main contains just two files: precompiled and concatenated css / js (usable default)
  3. Distribution repo contains also source assets, so if developer is concerned about the size of resulting javascript bundle, he/she can override main and pick individual javascript files (or source scss files)
  4. They don't include fonts, images, etc. in main.

So I think it's best if:

  1. Main contains only one, useful entry point for js + one useful entry point for css (precompiled).
  2. No other files in main, like .less, .coffee, .scss, fonts, images, etc.
  3. Provide also source files so developers can customize by overriding main.

Also, I think each file in main should be requirable on its own, so no files without wrapping UJS snippet.

Specifying consisting parts of Bootstrap makes it much easier to programmatically fetch them, filter out what I don't need and compile the rest.

I think better approach is to select files you need, not filter out what you don't.

I suggest naming them individually. This is the way it's done in bootstrap-sass.

Bootstrap-sass seems improper bower component anyway. It uses custom load path instead relative paths. Bower unfortunately doesn't allow for defining load paths for precompilers (maybe it's a good feature request? I think defining load paths is less ambiguous than "main" files).

I guess it's ok for javascript libraries to include multiple files in main, but just because each file can be required individually, and maybe author doesn't want to put distribution files in the repository.

Bootstrap's javascripts are a library, but bootstrap already includes concatenated javascripts in repository, so it's easier and more clear to just put one js in main instead 20.

All to all, I think main is just a useful default, and in our case it should contain only two files (js + css), because two files are the simplest thing to include to make bootstrap work on a website. KISS :)

Does it answer your question?

from spec.

sheerun avatar sheerun commented on June 16, 2024

On second thought maybe including main .less in bower.json is not that bad idea, because it's hard to guess load path for less files without main file. I think my stance on main is as follows:

Each entry of main should define both load path and main asset of that load path.

So for example

{
  "main": ["dist/js/foobar.js", "dist/css/foobar.css", "dist/less/foobar.less"]
}

Defines three load paths:

  1. dist/js for js compiler (browser, browserify etc.)
  2. dist/less for less compiler
  3. dist/css for css compiler (browser, grunt, jspm, ...)

And three main files for each compiler:

  1. foobar.js for js compiler
  2. foobar.less for less compiler
  3. foobar.css for css compiler

The only two required paths by bower would be for js and css compilers.

... but only until main is deprecated and replaced by something more sound.

from spec.

cvrebert avatar cvrebert commented on June 16, 2024

On second thought maybe including main .less in bower.json is not that bad idea

Yeah, it's become some level of de facto standard; see links+discussion in twbs/bootstrap#13328.

... but only until main is deprecated and replaced by something more sound.

That'll take a year at Bower's current rate.

from spec.

cvrebert avatar cvrebert commented on June 16, 2024

TL;DR:

  • main isn't going anywhere any time soon
  • main is de facto an array; normally it should have only one file per asset type

from spec.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.