Search code examples
zurb-foundationbowermodernizrbrunch

How to build Modernizr with bower and brunch - missing main in bower.json


I've read this github issue stating:

there isn't a main file to be in the main.

I have modernizr 3.0.0 installed automatically as a dependency of Foundation 5.5.2 and am trying to build my project with Brunch.

When running brunch build I get the following error:

Error: Component JSON file "/path/to/brunch-test/bower_components/modernizr/.bower.json" must havemainproperty. See https://github.com/paulmillr/read-components#README

So following the read-components issue, I am trying to override modernizr's main in my root bower.json but not sure how to go about it as there's no simple compiled modernizr.js present.

I know modernizr is meant to be customized, and indeed the modernizr 3 release news state there is a really cool solution of dynamically creating a custom package that can be installed via bower but I'm unable to find information about this?


Solution

  • Ok, I figured it out.

    So my directory tree is something along the lines of (simplified):

    /
    |-- bower.json
    |-- bower_components
      |-- modernizr
        |-- bin
          |-- modernizr
    

    I went into bower_components/modernizr and ran npm install to get the dependencies required to run the bin/modernizr builder.

    Then I went to their website to pick out the features I required: https://modernizr.com/download?setclasses

    Next, I clicked Build and downloaded the Command Line Config which I placed at the root directory of my project as modernizr-config.json.

    Then I ran bin/modernizr -c ../../modernizr-config.json which placed a custom built modernizr.js in /bower_components/modernizr/modernizr.js

    Finally, in my root bower.json, I added (following the read components issue:

    "overrides": {
      "modernizr": {
        "main": "modernizr.js"
      }
    }
    

    and brunch build is running beautifully now.