Skip to content
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

Better Grunt + Bower -> Removing Normalize.css from src/ #160

Merged
merged 6 commits into from
Aug 27, 2013

Conversation

ericf
Copy link
Collaborator

@ericf ericf commented Aug 7, 2013

This is a revamp of the Grunt + Bower setup to remove the need for checking Normalize.css into the src/ tree. As a result, forms-core.css has also been removed, because Pure really does depend on Normalize.css being on the page.

The Gruntfile has also been simplified, running grunt will install any Bower dependencies, run tests, and build Pure. The watch task first runs grunt (default), then observes changes and runs the test and build task, no Bower installing (so it's faster).


The also updates our npm dependencies to their latest versions.

ericf added 5 commits August 7, 2013 18:55
This also removes `forms-core.css` which was effectively Normalize.css'
form related styles prefixed with `.pure-form`.
Running `grunt` will now use Bower to install Normalize.css. As of 1.0.0
Bower got much faster, and it also uses a cache so the install only
happens once.

Added `grunt build` which does not the "import" or "test" tasks.
@@ -187,7 +157,7 @@ grunt.initConfig({
options: {
banner: [
'/*!',
'normalize.css v<%= normalize.version %> | MIT License | git.io/normalize',
'normalize.css v1.1.2 | MIT License | git.io/normalize',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this version be read from bower.json? I can imagine someone changing the version in bower.json and forgetting to change this value, too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it should. But it's a race condition, I'm trying to figure out how to process this in a function or something, after normalize has been installed via bower.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm, yeah, that is a pickle, then.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I created a bower-meta Grunt task which uses bower to load the metadata for all the Bower dependencies and add that data to Grunt's config object. But it makes the build take twice as long, 0.5sec to 1sec :( So I'm not sure this is going to be worth it.

grunt.registerTask('bower-meta', 'Make bower.json data available to Grunt.', function () {
    var bower = require('bower'),
        done  = this.async();

    bower.commands.list(null, {offline: true}).on('end', function (results) {
        var dependencies = results.dependencies;

        Object.keys(dependencies).forEach(function (name) {
            var dependency  = dependencies[name],
                meta        = dependency.pkgMeta,
                config      = {},
                bowerConfig = grunt.config.getRaw('bower') || {};

            if (!meta) {
                grunt.fatal('Bower dependency ' + name + ' not installed.');
            }

            config[name] = meta;

            // Merge dependency into `bower` config.
            grunt.config('bower', grunt.util._.merge(bowerConfig, config));
        });

        grunt.log.writeln('Loaded metadata for Bower packages.');
        done();
    });
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't the version specified in bower.json be solidified and then read from there, just like the package.json is read? No more race condition, only one place to edit, though slightly more laborious (no semver squishiness, not sure that's a bad thing, though).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I switch to doing that.

@tilomitra
Copy link
Contributor

@ericf Did you want to hold this back for 0.3.0 instead of merging it in for 0.2.2?

@ericf
Copy link
Collaborator Author

ericf commented Aug 21, 2013

@tilomitra correct, this is not a bug fix and is a pretty major change.

@ericf ericf merged commit f9bbf6f into pure-css:master Aug 27, 2013
@ericf ericf deleted the grunt-bower branch August 27, 2013 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants