Marking loader dependencies

If a loader uses external resources, such as when reading from a filesystem, the loader must indicate this. This information is used to invalidate "cacheable" loaders and recompile them in watch mode. What follows is a brief example of how to accomplish this, using the addDependency method inside of loader.js:

import path from 'path';
export default function(source) {
var callback = this.async();
var headerPath = path.resolve('header.js');
this.addDependency(headerPath);
fs.readFile(headerPath, 'utf-8', function(err, header) {
if(err) return callback(err);
callback(null, header + ' ' + source);
});
}

There are some differences between the loader and modular dependencies. Let's now discuss the latter.

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

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