[react-packager] Add assetRoots option
This commit is contained in:
parent
13e054a714
commit
319ea3242a
|
@ -45,6 +45,10 @@ if (options.root) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!options.assetRoots) {
|
||||
options.assetRoots = [path.resolve(__dirname, '..')];
|
||||
}
|
||||
|
||||
console.log('\n' +
|
||||
' ===============================================================\n' +
|
||||
' | Running packager on port ' + options.port + '. \n' +
|
||||
|
@ -97,6 +101,7 @@ function getAppMiddleware(options) {
|
|||
blacklistRE: blacklist(false),
|
||||
cacheVersion: '2',
|
||||
transformModulePath: require.resolve('./transformer.js'),
|
||||
assetRoots: options.assetRoots,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -134,13 +134,12 @@ DependecyGraph.prototype.resolveDependency = function(
|
|||
fromModule,
|
||||
depModuleId
|
||||
) {
|
||||
|
||||
if (this._assetMap != null) {
|
||||
// Process asset requires.
|
||||
var assetMatch = depModuleId.match(/^image!(.+)/);
|
||||
if (assetMatch && assetMatch[1]) {
|
||||
if (!this._assetMap[assetMatch[1]]) {
|
||||
console.warn('Cannot find asset: ' + assetMatch[1]);
|
||||
debug('WARINING: Cannot find asset:', assetMatch[1]);
|
||||
return null;
|
||||
}
|
||||
return this._assetMap[assetMatch[1]];
|
||||
|
|
Loading…
Reference in New Issue