gaearon/react-transform-boilerplate

Using file-loader to load image doesn't work?

hanfeisun opened this issue · 1 comments

I added this in module.loaders:

        {
            test: /\.jpe?g$|\.gif$|\.png$|\.svg$|\.woff$|\.ttf$|\.wav$|\.mp3$/,
            loader: require.resolve("file-loader") + "?name=../[path][name].[ext]"
        }

And in my src folder, I put an image file called gps1.png.

In a component in another js file, I wrote like this:

render() {
    return (
         <image width={1336} height={1104} xlinkHref={require('./gps1.png')}/>
)

The URL generated by file-loader is /static/../src/gps1.png. And it doesn't work.

When I access http://127.0.0.1:3000/src/gps1.png in the browser, it still redirect me to the index.html instead of the png file.

It seems that file-loader doesn't work well with react-transform-boilerplate.

this has been fixed and seems unrelated to react-transform-boilderplat...