olahol / reactpack

:package: build your react apps with one command and one `npm i`.
982 stars 36 forks source link

Support for GIFs (and other images) #12

Closed victorb closed 8 years ago

victorb commented 8 years ago

Today, you have the following part in the webpack configuration

  loaders.push({
    test: /\.(png)$/,
    loader: 'url?limit=100000'
  })

https://github.com/olahol/reactpack/blob/cc5692ee2332c10e6c14138227c214c7e6320539/config.js#L106-L109

Can we do something about other images as well, probably with a different loader? My guess is that the url-loader actually writes the image to base64 and puts it directly in the url, which wouldn't work for bigger images like GIFs or simply HQ ones.

victorb commented 8 years ago

Workaround in the meantime is to use the loader syntax when requireing things...

Example:

var happy_beardy = require('file?name=[hash]!./assets/laugh.gif')
// happy_beardy = hash with path to image in /dist
olahol commented 8 years ago

I've added gif to url-loader now, thank you @VictorBjelkholm.

victorb commented 8 years ago

Much better, thanks @olahol 👍