-
Notifications
You must be signed in to change notification settings - Fork 12.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use CSS partials and include a grunt task #1140
Conversation
}, | ||
concat: { | ||
dist: { | ||
src: ['<banner>', 'css/_normalize.css', 'css/_base.css', 'css/_helpers.css', 'css/_media.css'], |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
Amended commit to integrate this and @mathiasbynens's feedback. Any other general thoughts or comments on the approach? |
I’m not a big fan of dependencies in general, but as Grunt works pretty much everywhere (and is amazingly awesome), I’m okay with it in this case. +1 to splitting up the CSS like this. Much cleaner. I just hope it won’t confuse people too much, or cause them to reference more than once CSS file in the HTML. |
It's almost a dev dependency as there is no requirement to use grunt from end users. We'll have to make it as clear as possible what is going on. It does pain me a little to have more files added to the root, and soon a metro icon too. Maybe one day we'll put the touch icons in the Might put a tweet out and get some eyeballs on this stuff so we can see what needs to be clarified. |
Why not put the dev stuff in a dev folder? build tools, separate CSS files etc, and get the build script to output to /css (the project's CSS, not H5BP's dev CSS) — i.e. separate what is H5BP's tools and what is space for the user's project being built using H5BP |
Hmmm. I think the separate CSS files and build step is the way to go during normal project development, and I'd be ok with encouraging it. But as you mentioned in a previous discussion, doing it this way doesn't exclude people who would rather stick to the single-file-no-dependencies approach. |
|
||
HTML5 Boilerplate comes with a very simple | ||
[grunt](https://github.com/cowboy/grunt) file to get you started with a build | ||
process. It comes with basic 'watch' and 'concentenate' tasks that can be used |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
Nicolas, this is great work! Two things I wanted to mention: 1. We could define a
Running 2. The version number could be something like All in all it looks clean and well done. I like the |
I’m okay with these changes, but I participate here to be a word of warning, that if a user has to install anything to use H5BP then you have failed. It is my right to choose my development tools and not to burden others with them either, no matter how rad I think they are. :) |
Breaking up the CSS into different files has several benefits: * Normalize.css can be included as a drop-in. This makes it easier to apply upstream changes and track which version of normalize.css is included in HTML5 Boilerplate. * Easier for people to remove or replace parts of the CSS. For example, if someone would rather use their own custom reset, they can pull out normalize.css without any trouble. * Encourages people to use multiple files in development. You wouldn't (or shouldn't) write all your JavaScript in one huge file. The same goes for CSS. * A step towards making it easier to integrate HTML5 Boilerplate into larger application frameworks. Included as part of this change is the addition of a package.json and simple grunt.js file. The package.json file allows us to group various pieces of information about the project, such as the version number. It will also act as the place to list any Node package dependencies, such as the H5BP node-build-script. The grunt.js file sets up grunt 'concat' and 'watch' tasks to combine the separate CSS files into a single main file. People can either edit the main file directly or continue to use the grunt task during development. Using the grunt tasks relies on a user of the boilerplate having Node.js, npm, and grunt installed. These are technologies that can be used on any OS and are particularly well suited for use by Front End developers. Ref #1132
I'm a fan of this idea however I think there should still be a simplified version of H5BP for the average user. Not everybody understands grunt and if H5BP is meant to be a simple out-of-the-box tool then we don't want to discourage other developers. |
You wouldn't need grunt. |
+1 for this. |
You can exclude compiled files from the repo and still provide a way to download (even customize) without dependencies. All done in the browser. We do this on jmpress.js: http://shama.github.com/jmpress.js/docs/#builder /cc @sokra We use grunt and have a grunt task for it: https://github.com/sokra/grunt-webpack |
The problem with excluding the compiled file (in this case), is that it then requires end users to install node.js and run the grunt task to have the boilerplate work out-of-the-box if they got the code from anywhere other than an online builder like Initializr. |
I think half of H5BP users are those who have absolutely no clue on build tools. Personally, this is like the best idea ever, but I am just concerned that this might alienate such users even further? Perhaps there should be a way for them to exclude these files from being downloaded on Initializr? cc: @verekia |
Also I would like to point out that jQuery and jQuery UI both use grunt. |
Howdy I'm a little concerned with some aspects of this pull request and put my opinion here to have it out there. But it's just that, an opinion. Splitting css files is goodNo brainer really. The existing css file has always been a little hard to integrate with other projects - and the reason is simply because the rules are order-sensitive and the project-specific rules go in the middle. For this reason I'm quite happy to see multiple css files in the repository. Creating multiple css files makes it easier to maintain the files, and generally allows more developer freedom. Duplication in a repository is badThese changes put each css rule in 2 files. It doesn't matter how big a comment you put in main.css - there will still be:
Don't add built-assets to the repositoryAny file that you can derive from something else in the repository doesn't belong in the repository. As such I echo @shama's comment that they don't /have/ to be in the repository - they could be added as part of a download process, and that's how jquery and jquery-ui do it. If you want to ensure that the download from github works without problems why not make
Bearing in mind that the file should be only used in that form in development and purely to ensure it works. In development multiple files is easier to work withif you have
In development, editing your css files is potentially a lot easier, and the benefits of pre-processing the css files are preserved without compromising on committing all css rules in 2 places. Best practices not toolsAnd finally - I know grunt is a great tool, but I have the perception that this project is becoming less about markup and coding practices and more about which tools to use. |
Yay, I've been breaking the css up manually to use with my own css packager. Nice to know I won't have to be doing that anymore. |
Ideally, yes.
Those projects never set out to be used by cloning the github repo.
Because there is no way we would be able to ensure that people didn't put things in production using
Agreed. The problem with wrapping build script comments around the files is that most people will never use the build script and they'll end up with multiple HTTP requests. Having said that, including multiple
What gives you that perception? The commit log doesn't justify it. Besides, this project was never just about HTML and coding practices, it has always been to about helping people to "build fast, robust, adaptable, and future-proof websites". This is one pull request that is looking to encourage a good practice and be improved through feedback. The current commit avoids imposing hard tooling requirements, and the project currently has fewer dependencies and bundled tools than it did back when it had the ant build script and qunit included. But if one day adding a basic tooling dependency is what keeps this project useful and relevant, then so be it. |
I want to propose another option, which supports build tools and cloning to repo. Make two parallel branches:
Commits should be applied to the first branch (there are not duplicate things, so it do not make your history noisy) On releases a merge commit is applied to the second one, including all changes in the first branch (thought the merge) and a compile step. Your users can clone the second brach easily as it includes the compiled files and the user need no build tool. The first branch acts nicely for the developer with the points @AD7six made. |
I agree with the above comments about "user firiendly-ness" for all users. As with many people, I learned a lot from this project. My only concern with the proposed idea is that new developers will become alienated. Two branches, "Advanced" and "Not-so-advanced" sounds like a fair compromise for all users. Though, in fairness, I will admit that maintaining two main branches can also create a challenge. |
yeah it's a bit of a challenge. But the challenge is on developer side not on user side. ;) |
@nimbupani Yep, I can definitely have an option on Initializr (and on your Customize Boilerplate builder) to choose between the dev and the prod version of the CSS. Just like there is a minified or development jQuery option. |
IMHO we should encourage users to do-the-right-thing™. So, to do this and teach it to the users I would:
What do you think? |
And what if I don't think grunt is the RightThing^tm? Never force Solution IMO is to put all the build stuff in a "dev" folder and --Kroc ----- Original Message ----- IMHO we should encourage users to do-the-right-thing™. So, to do this and teach it to the users I would:
Links:[1] |
Maybe I didn't explain well in my previous comment:
So on the site we'll have two version: the development and the production version. |
Here’s an idea: What if H5BP was a sub-folder of the build system? That is, the user can download either the outer folder (the build system, and H5BP within) or the inner folder (just H5BP). This would also work well with git; H5BP would just be a sub-module of the build system. |
i like @Kroc approach |
Separate BranchesSeparating the development from the production is not what I think is best for the user. We don't want the user to choose what is the right thing for him because he/she might not know. It is confusing to have two branches that look kinda the same but you have to decide which one to take. And what should be the default branch, dev or prod? I'd rather go with dev, but if people download that and get a 404 for the styles.css file they get confused and confusion is not what we should aim for IMO. A
|
OK, since this has spawned a whole new set of problems/proposals, it should probably be abandoned. However, I'd like to disentangle normalize.css from the html5 boilerplate CSS, so I'm thinking that we go for a much simpler approach for now and just have 2 CSS files referenced in the HTML - |
Benefits of disentangling normalize.css from the rest of the project's CSS: * Easier to track normalize.css version. * Easier to update normalize.css. * Easier to remove normalize.css if the user wants. * Clearer distinction between normalizing CSS and the additions that HTML5 Boilerplate provides. Drawback is the additional HTTP request incurred from the extra stylesheet referenced in the HTML. However, we already do something similar for the JS, and anyone serious about performance is going to employ a build process to concatenate and minify CSS/JS. Ref gh-1132 Ref gh-1140
Closing. Anyone interested still has time to review #1160. Thanks for all the great feedback and alternative ideas. |
Benefits of disentangling normalize.css from the rest of the project's CSS: * Easier to track normalize.css version. * Easier to update normalize.css. * Easier to remove normalize.css if the user wants. * Clearer distinction between normalizing CSS and the additions that HTML5 Boilerplate provides. Drawback is the additional HTTP request incurred from the extra stylesheet referenced in the HTML. However, we already do something similar for the JS, and anyone serious about performance is going to employ a build process to concatenate and minify CSS/JS. Ref gh-1132 Ref gh-1140
Breaking up the CSS into different files has several benefits:
apply upstream changes and track which version of normalize.css is
included in HTML5 Boilerplate.
if someone would rather use their own custom reset, they can pull out
normalize.css without any trouble.
(or shouldn't) write all your JavaScript in one huge file. The same
goes for CSS.
larger application frameworks.
Included as part of this change is the addition of a package.json and
simple grunt.js file. The package.json file allows us to group various
pieces of information about the project, such as the version number. It
will also act as the place to list any Node package dependencies, such
as the H5BP node-build-script.
The grunt.js file sets up grunt 'concat' and 'watch' task to combine the
separate CSS files into a single main file. People can either edit the
main file directly or continue to use the grunt task during development.
This relies on a user of the boilerplate having Node.js, npm, and grunt
installed. These are technologies that can be used on any OS and are
particularly well suited for use by Front End developers.
Ref #1132