How to load resolution of multiple node module loaders?
I made several loaders available in the npm module. I want different projects to load these webpack loaders based on needs. So I have included them in one module. How do I add these loaders to my webpack config?
Below are the ways I tried for a module named test-module
and loadertest-loader
1), expecting it to resolve the module directly ( test-loader
even installed via export) and using the loader.
loader: 'test-module/test-loader'
2) Tried adding config in resolveLoader
resolveLoader: {
modules: ['node_modules', 'test-module'],
extensions: ['.js', '.json'],
mainFields: ['loader', 'main'],
}
and also
loader: 'test-loader'
3) Even tried to provide relative path to folder
resolveLoader: {
modules: ['node_modules', 'node_modules\test-module\loaders'],
extensions: ['.js', '.json'],
mainFields: ['loader', 'main'],
}
and also
loader: 'test-loader'
All of the above didn't work. But directly providing the relative path in the loader worked.
loader: './node_modules/test-module/'
Is there a better way to provide relative paths?
source to share
No one has answered this question yet
Check out similar questions: