Home > Web Front-end > JS Tutorial > Configuration method of bower overrides

Configuration method of bower overrides

一个新手
Release: 2017-09-21 09:43:35
Original
1960 people have browsed it

Bower is a commonly used package management tool. It is very similar to npm in use, but there are some differences between the two. You can refer to - What is the difference between Bower and npm. I won’t talk about bower itself here, but I want to talk about bower’s overrides configuration.

What is override

Override itself means override. In fact, its function is also to override the original configuration of the dependent package. If you manually introduce bower dependency package files, this configuration is useless, but when you use automatic injection tools such as wiredep, overrides are very useful.

For example, we use bower to install the ace-builds package:

bower install ace-builds --save
Copy after login

Then use wiredep to automatically inject bower dependencies:

$ node
> require('wiredep')({ src: 'index.html' });
Copy after login

(For specific commands, see wiredep documentation)

You will find that none of the ace-builds related files are injected into index.html. Why is this?

Open the bower.json file of the dependency package of ace-builds:

Configuration method of bower overrides

You will find that the main option is not configured in it. The automatic injection of wiredep actually determines which files to inject based on the main option in each dependency package. Without main, wiredep cannot be automatically injected.

This is where the overrides option comes in handy. We can define it like this:

"overrides": {
    "ace-builds": {
      "main": [        "src-min-noconflict/ace.js",        "src-min-noconflict/mode-yaml.js",        "src-min-noconflict/mode-javascript.js",        "src-min-noconflict/theme-github.js",        "src-min-noconflict/ext-language_tools.js"
      ]    }  }
Copy after login

Indicate the files we need to automatically inject.

The above is the detailed content of Configuration method of bower overrides. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template