5
5
[ Documentation: Using loaders] ( http://webpack.github.io/docs/using-loaders.html )
6
6
7
7
``` javascript
8
- var url = require (" file!./file.png" );
8
+ var url = require (" file-loader !./file.png" );
9
9
// => emits file.png as file in the output directory and returns the public url
10
10
// => returns i. e. "/public-path/0dcbbaa701328a3c262cfd45869e351f.png"
11
11
```
@@ -17,7 +17,7 @@ By default a file is emitted, however this can be disabled if required (e.g. for
17
17
side packages).
18
18
19
19
``` javascript
20
- var url = require (" file?emitFile=false!./file.png" );
20
+ var url = require (" file-loader ?emitFile=false!./file.png" );
21
21
// => returns the public url but does NOT emit a file
22
22
// => returns i. e. "/public-path/0dcbbaa701328a3c262cfd45869e351f.png"
23
23
```
@@ -44,27 +44,27 @@ use `?name=[path][name].[ext]`.
44
44
## Examples
45
45
46
46
``` javascript
47
- require (" file?name=js/[hash].script.[ext]!./javascript.js" );
47
+ require (" file-loader ?name=js/[hash].script.[ext]!./javascript.js" );
48
48
// => js/0dcbbaa701328a3c262cfd45869e351f.script.js
49
49
50
- require (" file?name=html-[hash:6].html!./page.html" );
50
+ require (" file-loader ?name=html-[hash:6].html!./page.html" );
51
51
// => html-109fa8.html
52
52
53
- require (" file?name=[hash]!./flash.txt" );
53
+ require (" file-loader ?name=[hash]!./flash.txt" );
54
54
// => c31e9820c001c9c4a86bce33ce43b679
55
55
56
- require (" file?name=[sha512:hash:base64:7].[ext]!./image.png" );
56
+ require (" file-loader ?name=[sha512:hash:base64:7].[ext]!./image.png" );
57
57
// => gdyb21L.png
58
58
// use sha512 hash instead of md5 and with only 7 chars of base64
59
59
60
- require (" file?name=img-[sha512:hash:base64:7].[ext]!./image.jpg" );
60
+ require (" file-loader ?name=img-[sha512:hash:base64:7].[ext]!./image.jpg" );
61
61
// => img-VqzT5ZC.jpg
62
62
// use custom name, sha512 hash instead of md5 and with only 7 chars of base64
63
63
64
- require (" file?name=picture.png!./myself.png" );
64
+ require (" file-loader ?name=picture.png!./myself.png" );
65
65
// => picture.png
66
66
67
- require (" file?name=[path][name].[ext]?[hash]!./dir/file.png" )
67
+ require (" file-loader ?name=[path][name].[ext]?[hash]!./dir/file.png" )
68
68
// => dir/file.png?e43b20c069c4a01867c31e98cbce33c9
69
69
```
70
70
0 commit comments