File tree Expand file tree Collapse file tree 1 file changed +25
-9
lines changed
Expand file tree Collapse file tree 1 file changed +25
-9
lines changed Original file line number Diff line number Diff line change 1515 <h1 >JSON Loader</h1 >
1616</div >
1717
18+ ** Note: Since webpack v2, JSON files will work by default. You might still want to use this if you use a custom file extension.**
19+
1820<h2 align =" center " >Install</h2 >
1921
2022``` bash
@@ -23,29 +25,43 @@ npm install --save-dev json-loader
2325
2426<h2 align =" center " >Usage</h2 >
2527
26- ** require**
27- ``` js
28- const json = require (" json!./file.json" )
29- ```
3028
31- ** webpack.config.js**
32- ``` js
33- const json = require (' file.json' )
34- ```
29+ ### Configuration (recommended)
3530
31+ ** webpack.config.js**
3632``` js
3733module .exports = {
3834 module: {
3935 rules: [
4036 {
4137 test: / \. json$ / ,
42- use: [ ' json-loader' ]
38+ use: ' json-loader'
4339 }
4440 ]
4541 }
4642}
4743```
4844
45+ ``` js
46+ import json from ' file.json' ;
47+ ```
48+
49+ ### CLI
50+
51+ ``` bash
52+ webpack --module-bind ' json=json-loader'
53+ ```
54+
55+ ``` js
56+ import json from ' file.json' ;
57+ ```
58+
59+ ### Inline
60+
61+ ``` js
62+ import json from ' json-loader!file.json' ;
63+ ```
64+
4965<h2 align =" center " >Maintainer</h2 >
5066
5167<table >
You can’t perform that action at this time.
0 commit comments