You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 21eb499
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: README.md
+50-5Lines changed: 50 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -105,7 +105,7 @@ Somethings it happens that browsers require other code than node.js do.
105
105
`webpack` allow module developers to specify replacements which are used in the compile process of `webpack`.
106
106
107
107
Modules in `web_modules` replace modules in `node_modules`.
108
-
`filename.web.js` replaces `filename.js` when required without file extention.
108
+
`filename.web.js` replaces `filename.js` when required without file extension.
109
109
110
110
in options: `alias: { "http": "http-browserify" }`
111
111
@@ -490,7 +490,7 @@ else `stats` as json see [example](modules-webpack/tree/master/examples/code-spl
490
490
require JSON
491
491
</td>
492
492
<td>
493
-
no
493
+
yes (NEW)
494
494
</td>
495
495
<td>
496
496
no
@@ -517,14 +517,29 @@ else `stats` as json see [example](modules-webpack/tree/master/examples/code-spl
517
517
518
518
<tr>
519
519
<td>
520
-
compile coffee script
520
+
loaders
521
+
</td>
522
+
<td>
523
+
yes (NEW)
521
524
</td>
522
525
<td>
523
526
no
524
527
</td>
525
528
<td>
526
529
no
527
530
</td>
531
+
</tr>
532
+
533
+
<tr>
534
+
<td>
535
+
compile coffee script
536
+
</td>
537
+
<td>
538
+
yes (NEW)
539
+
</td>
540
+
<td>
541
+
no
542
+
</td>
528
543
<td>
529
544
yes
530
545
</td>
@@ -606,6 +621,38 @@ else `stats` as json see [example](modules-webpack/tree/master/examples/code-spl
606
621
</tr>
607
622
</table>
608
623
624
+
## Loaders
625
+
626
+
You can use a syntax for loader plugins to preprocess files before emitting javascript code to the bundle.
627
+
628
+
The following example loads the raw content of a file with the `raw` loader:
629
+
630
+
```javascript
631
+
var content =require("raw!./file.txt");
632
+
```
633
+
634
+
Multiple loader plugins can be prepended by seperating them with `!`.
635
+
The loader plugins are resolved like in normal `require` call but with different default extension.
636
+
637
+
The `raw` loader plugin is looked up at modules `raw-webpack-web-loader`, `raw-webpack-loader`, `raw-web-loader`, `raw-loader`, `raw`
638
+
and the following files are looked up: `index.webpack-web-loader.js`, `index.webpack-loader.js`, `index.web-loader.js`, `index.loader.js`, `index`, `index.js`.
639
+
Note that the `web-` versions are omitted if loaders are used in node.js.
640
+
641
+
See [example](modules-webpack/tree/master/examples/loader).
642
+
643
+
The following loaders are included as optional dependencies:
644
+
645
+
*`raw`: Loads raw content of a file
646
+
*`json` (default at `.json`): Loads file as JSON
647
+
*`jade` (default at `.jade`): Loads jade template and returns a function
648
+
*`coffee` (default at `.coffee`): Loads coffee-script like javascript
649
+
650
+
TODO
651
+
652
+
*`css`: CSS rules are added to DOM on require
653
+
*`less`, `sass`: like `css` but compiles
654
+
655
+
609
656
## Tests
610
657
611
658
You can run the unit tests with `npm test`.
@@ -619,8 +666,6 @@ node build
619
666
620
667
and open `test.html` in browser. There must be several OKs in the file and no FAIL.
621
668
622
-
TODO more tests
623
-
624
669
## Contribution
625
670
626
671
You are welcome to contribute by writing issues or pull requests.
0 commit comments