Avoiding absolute paths

As alluded to, inserting absolute paths into any code related to a module should not be done, as hashing will break if the root directory is ever moved. Also, note that there is a stringifyRequest method in the loader-utils loader, which can be used to an absolute path to a relative one to help automate your process.

Refer to Chapter 2Working with Modules and Code Splitting, to get a refresher on absolute paths if you think you need it.

As with common code, this is something very fundamental to how Webpack works, and if you don't have that in mind during your authoring you may overlook it, so it is certainly worth mentioning. Relative paths are the way to go.

One last point on standards relates to peer dependencies. Let's look at these now.

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

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