Webpack Outputs Wrong Path For Images
I'm building a site with react and webpack. When I build the app with webpack and try to include images, the images are written to the build folder along with the other assets, but
Solution 1:
You could try setting the name option for file-loader, as well as output.publicPath
.
output: {
path: 'build/',
file: 'bundle.js',
publicPath: '/assets'
}
...
{
test: /\.(png|jpg)$/,
loader: 'file-loader?name=/img/[name].[ext]'
}
Then the resolved url in your require will be:
/assets/img/news-feed-icon.png
Post a Comment for "Webpack Outputs Wrong Path For Images"