Reputation: 3372
My loader (external-svg-sprite-loader) requires access to the option output.publicPath
defined in the webpack configuration file. According to webpack 2 documentation the this.options
property in the Loader API was deprecated, which means at some point my loader will no longer work. Is there another way of accessing this value or of generating a URL based on the value of output.publicPath
?
Upvotes: 1
Views: 422
Reputation: 3372
The solution was to use the compile time variable __webpack_public_path__
.
Upvotes: 0
Reputation: 147
The webpack2 docs talk about using the LoaderOptionsPlugin to pass options to your loader context. So in this case, for options.output.publicPath
one could add this to their webpack plugins config:
new webpack.LoaderOptionsPlugin({
test: /\.svg$/,
options: {
output: {
publicPath: options.publicPath,
},
},
}));
see also what's new in webpack2
Upvotes: 1