How to import bower_components using an application created by brunch?

I still feel my attitude towards breakfast. I have a fundamental class and jasmine specification that have been built and successfully tested.

Now it's time to import other dependencies for use, the first of which will be jQuery and make $available. Libraries are already configured and loaded into the directory bower_components.

While my configuration has changed a bit, it would be useful to point out the skeleton I started with: brunch-with-hipsters .

How do you import and make jQuery available as $to my coffeescript class from bower_components?

+4
source share
2 answers

So, it was a small red herring.

coffeelintwas turned on and gave me warnings when starting the brunch, but from the very beginning I was not worried about it. However, there were enough warnings that it was scrolling from the screen.

I noticed that I configured:

        'js/vendor.js': /^(bower_components|vendor)/
        'js/app.js': /^app/

until vendor.js appeared. Scrolling, I found this error:

error: [Error: Component JSON file ".../bower_components/jquery-simulate/.bower.json" 
must have `main` property. See https://github.com/paulmillr/read-components#README]

Simply put, I needed to provide a section overridesbecause it jquery-simulatedoes not provide a .bower.json file (I access it directly from git).

In the end, this fix meant vendor.js was created and $ was available.

+2
source

npm install -g bower, brunch-config.[js|coffee], Bower vendor.js app.js joinTo, Brunch config doc.

, brunch watch . bower.json Bower deps ( ), .

. Bower main, overrides, main , read-components. .

0
source

Source: https://habr.com/ru/post/1534743/


All Articles