Dmitry
Dmitry

Reputation: 7563

How to build dependency (ex highlight.js) with bower?

I added highlight.js to bower.json and installed it.

But there are only sources of highlight.js, how can I compile it using bower?

Upvotes: 1

Views: 211

Answers (2)

Andi N. Dirgantara
Andi N. Dirgantara

Reputation: 2051

Bower is just download the dependencies. Installation is depends on what development environment are you at? Single page application with Yeoman? Node.JS web application with Express? Or something else.

There are some JS task runners like grunt or gulp. I prefer grunt. If you are using grunt, there is exist grunt's task runner for it called grunt-bower-task that will install your downloaded bower components into specific folder that meets our need.

I recommend you to use/ learn Yeoman that is included yo the scaffolding, bower the dependencies manager, and grunt the task runner if you are starting single page application development.

So basically bower is just front end dependency manager unlike NPM which is NodeJS dependency/ package manager that we usually use at backend/ web server.

Upvotes: 2

hjl
hjl

Reputation: 2802

since you are using bower to install highlight.js, i believe it's used at client side.

you don't need to compile javascript at all, you just need to load it and use it globally.

there are several ways to load it into global execution context:

  • inline script in html <script src="path/to/bower/component/highlight.js"></script>

  • using front-end AMD modularization tool like requirejs

  • use front-end CMD modularization tool like browserify, webpack

Upvotes: -1

Related Questions