Skip to content

Commit 49dfd01

Browse files
author
evilebottnawi
committed
Changed: no longer required to transfer options for figter using config option.
Changed: to load configuration from file, need specify `useConfigFile` option. Chore: no need to use function `encodeURI` for `query string`.
1 parent c906700 commit 49dfd01

File tree

9 files changed

+210
-198
lines changed

9 files changed

+210
-198
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
This project adheres to [Semantic Versioning](http://semver.org/).
66

7+
# Head
8+
9+
- Changed: no longer required to transfer options for `figter` using `config` option.
10+
- Changed: to load configuration from file, need specify `useConfigFile` option.
11+
- Chore: no need to use function `encodeURI` for `query string`.
12+
713
# 1.1.1 - 2017-01-31
814

915
- Fixed: updated webpack peer dependency to support `2.2.1`.

README.md

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ module.exports = {
6767
module: {
6868
loaders: [
6969
{
70-
loader: "figlet",
70+
loader: "figlet?useConfigFile",
7171
test: /\.figletrc$/, // or "/\.figletrc\.json$/", or "/\.figletrc\.js$/"
7272
}
7373
]
@@ -83,11 +83,17 @@ module.exports = {
8383
Alternative configurations supported dynamic configuration:
8484

8585
```javascript
86+
const querystring = require('querystring');
87+
const figletConfig = {
88+
options: {},
89+
text: "ANOTHER-TEXT"
90+
};
91+
8692
module.exports = {
8793
module: {
8894
loaders: [
8995
{
90-
loader: `figlet?config=${encodeURI(JSON.stringify(figletConfig))}`,
96+
loader: `figlet?config=${JSON.stringify(figletConfig)}`,
9197
test: /figlet$/
9298
}
9399
]
@@ -100,17 +106,44 @@ module.exports = {
100106
}
101107
```
102108

103-
Note: `webpack` normalize `query` to `loader`, if you want to specify `url` in `outputTextBefore` or `outputTextAfter`,
104-
then use `'Visit Site - https:\\/\\/itgalaxy.company'`.
109+
In `webpack 2` your can use this config:
110+
111+
```javascript
112+
const figletConfig = {
113+
options: {},
114+
text: "ANOTHER-TEXT"
115+
};
105116

106-
Using `config` through `query string` is have large priority than through `resolve.alias`.
117+
module.exports = {
118+
module: {
119+
loaders: [
120+
{
121+
loader: `figlet-loader`,
122+
options: figletConfig,
123+
test: /figlet$/
124+
}
125+
]
126+
},
127+
resolve: {
128+
alias: {
129+
figlet$: path.resolve(__dirname, "path/to/empty-file") // You can add comment "Please do not delete this file" in this file
130+
}
131+
}
132+
}
133+
```
107134

108-
Option `figletConfig` must contain `text` and `options` as above in **Initialization** section.
135+
Config should always contains `text` and `options` as above in **Initialization** section.
109136

110137
### Usage
111138

112139
Now you are able to import your custom figlet build as a module throughout your application like so:
113140

141+
```javascript
142+
const figlet = require('figlet');
143+
```
144+
145+
Or
146+
114147
```javscript
115148
import 'figlet';
116149
```

__tests__/fixtures/.figletrc-invalid.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"options": {
33
"font": "NonexistsFont"
44
},
5-
"text": "ANOTHER-TEXT"
5+
"text": "ANOTHER-TEXT-INVALID"
66
}

__tests__/fixtures/.figletrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ module.exports = {
99
kerning: "default",
1010
verticalLayout: "default"
1111
},
12-
text: "ANOTHER-TEXT"
12+
text: "ANOTHER-TEXT-JS-RC"
1313
};

__tests__/fixtures/.figletrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
"kerning": "default",
88
"verticalLayout": "default"
99
},
10-
"text": "ANOTHER-TEXT"
10+
"text": "ANOTHER-TEXT-JSON-RC"
1111
}

__tests__/fixtures/.figletrc1.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)