[add] support directly requiring image assets

Thanks to IjzerenHein <hrutjes@gmail.com>. See #84
This commit is contained in:
Nicolas Gallagher
2016-03-08 18:03:45 -08:00
parent 77d201988d
commit 6d7d98c149
4 changed files with 72 additions and 16 deletions

View File

@@ -16,6 +16,25 @@ module.exports = {
}
```
## Image assets
In order to require image assets (e.g. `require('assets/myimage.png')`), add
the `url-loader` to the webpack config:
```js
// webpack.config.js
module.exports = {
// ...
module: {
loaders: {
test: /\.(gif|jpe?g|png|svg)$/,
loader: 'url-loader',
query: { name: '[name].[hash:16].[ext]' }
}
}
```
## Web-specific code
Minor platform differences can use the `Platform` module.