MacKentoch / react-redux-bootstrap-webpack-starter

React 16.14 + Typescript + React-Router 5 + Redux + Bootstrap 4 + Hot Reload + redux-devtools-extension + Webpack 5 + styled-components STARTER
141 stars 47 forks source link

couldn't require image #9

Closed ycang89 closed 5 years ago

ycang89 commented 7 years ago

tried to include an image in the page by <img src={require('../../../../preview/preview.png')}/> but it doesn't work in "npm run serve-dev mode" and "npm run serve-prod mode". The output path is wrong.

ycang89 commented 7 years ago

i have resolve this issue by add "publicPath" { test: /\.(eot|woff|woff2|ttf|svg|png|jpe?g|gif)(\?\S*)?$/, use: [ { loader: 'file-loader', options: { publicPath: '/public/assets/', name: '[name].[ext]' } } ] }

please check if this help.