Resolving module dependencies

Depending on the type of module you are using, there may be a different schema in use to specify any dependency. In Cascading Style Sheets (CSS), for example, the @import and URL(...) statements are used. When doing this, these dependencies should be resolved by the module system.

This can be achieved in one of the following two ways:

  • By transforming the statements to require statements
  • Using the this.resolve function to resolve a path

The css-loader is a good example of the first approach. It transforms dependencies to require statements, by replacing @import statements with a request to the other style sheet and url(...) with a request to the file being referenced.

In respect to the LESS loader, each @import statement is unable to transform to a require statement because fewer files must be compiled in a single iteration. As a result, the LESS loader will use custom path-resolving logic to extend the LESS compiler. It will then use the this.resolve method to resolve the dependency.

If you're using language that only accepts relative Uniform Resource Locators (URLs), the ~ tilde convention can be used to specify references to the installing modules. An example would be url('~some-library/image.png').

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.40.207