I have a library that is packaged using webpack. I've used file-loader with below config:
{
//file-loader config of library
test: /\.(tsv|json)$/,
loader: 'url-loader?name=[name].[ext]'
}
When a webpack build is run, the files are stored in dist/ folder as expected. All my references to these files does work fine if I host the dist folder of library.
I use the above library in other project(also a webpack proj) as a dependency using npm.
To access components of lib in the project, I use the ProviderPlugin as:
new webpack.ProvidePlugin({
myCustomLib: '<myLibName>'
})
With this setup I can access the library classes(ES6) as myCustomLib.LibraryClassName with no issues.
But the project fails loading URL's configured in library as the project's file loader config is different:
{
//file-loader config of project using the library
test: /\.(tsv)$/,
loader: 'file-loader?name=assets/[name].[ext]'
}
All my library files are getting placed in dist/assets/ but my library code expects it to be from dist/. How do I tweak the project config to handle this case. Or have I taken a totally wrong approach. Is there something I should correct