|
| 1 | +# figlet-loader |
| 2 | + |
| 3 | +[](https://www.npmjs.org/package/figlet-loader) [](https://travis-ci.org/itgalaxy/figlet-loader) [](https://david-dm.org/itgalaxy/figlet-loader) [](https://david-dm.org/itgalaxy/figlet-loader?type=dev) |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +```shell |
| 8 | +$ npm install figlet-loader --save-dev |
| 9 | +``` |
| 10 | + |
| 11 | +## Initialization |
| 12 | + |
| 13 | +You have to create a `.figletrc` configuration file and put your figlet stuff in it. Like so |
| 14 | + |
| 15 | +```json |
| 16 | +// .figletrc or .figletrc.json |
| 17 | +{ |
| 18 | + "options": { |
| 19 | + "outputTextBefore": "TEXT BEFORE", |
| 20 | + "outputTextBeforeEscape": true, |
| 21 | + "outputTextAfter": "TEXT AFTER", |
| 22 | + "outputTextAfterEscape": true, |
| 23 | + "font": "ANSI Shadow", |
| 24 | + "horizontalLayout": "default", |
| 25 | + "kerning": "default", |
| 26 | + "verticalLayout": "default" |
| 27 | + }, |
| 28 | + "text": "ANOTHER-TEXT" |
| 29 | +} |
| 30 | +``` |
| 31 | + |
| 32 | +Full list of supported **"options"** and their **"description"** can be found in [figlet](https://github.com/patorjk/figlet.js). |
| 33 | + |
| 34 | +### Webpack config |
| 35 | + |
| 36 | +[Documentation: Using loaders](http://webpack.github.io/docs/using-loaders.html) |
| 37 | + |
| 38 | +Put the following code to your webpack config file: |
| 39 | + |
| 40 | +```javascript |
| 41 | +module.exports = { |
| 42 | + module: { |
| 43 | + loaders: [ |
| 44 | + { |
| 45 | + loader: "figlet", |
| 46 | + test: /\.figletrc$/, // or "/\.figletrc\.json$/" |
| 47 | + } |
| 48 | + ] |
| 49 | + }, |
| 50 | + resolve: { |
| 51 | + alias: { |
| 52 | + figlet$: path.resolve(__dirname, "path/to/.figletrc") // or "path/to/.figletrc.json" |
| 53 | + } |
| 54 | + } |
| 55 | +} |
| 56 | +``` |
| 57 | + |
| 58 | +Using configuration through `resolve.alias` supported only `JSON` **(PR welcome)**. |
| 59 | + |
| 60 | +Alternative configurations supported dynamic configuration: |
| 61 | + |
| 62 | +```javascript |
| 63 | +module.exports = { |
| 64 | + module: { |
| 65 | + loaders: [ |
| 66 | + { |
| 67 | + loader: `figlet?config=${encodeURI(JSON.stringify(figletConfig))}`, |
| 68 | + test: /figlet$/ |
| 69 | + } |
| 70 | + ] |
| 71 | + }, |
| 72 | + resolve: { |
| 73 | + alias: { |
| 74 | + figlet$: path.resolve(__dirname, "path/to/empty-file") // You can add comment "Please do not delete this file" in this file |
| 75 | + } |
| 76 | + } |
| 77 | +} |
| 78 | +``` |
| 79 | + |
| 80 | +Using `config` through `query string` is have large priority than through `resolve.alias`. |
| 81 | + |
| 82 | +Option `figletConfig` must contain `text` and `options` as above in **Initialization** section. |
| 83 | + |
| 84 | +### Usage |
| 85 | + |
| 86 | +Now you are able to import your custom figlet build as a module throughout your application like so: |
| 87 | + |
| 88 | +```javscript |
| 89 | +import 'figlet'; |
| 90 | +``` |
| 91 | + |
| 92 | +You can used [bundle](https://github.com/webpack/bundle-loader) plugin for async loading: |
| 93 | + |
| 94 | +```javscript |
| 95 | +import 'bundle!figlet'; |
| 96 | +``` |
| 97 | + |
| 98 | +## Related |
| 99 | + |
| 100 | +- [figlet](https://github.com/patorjk/figlet.js) - API for this module |
| 101 | + |
| 102 | +## Contribution |
| 103 | + |
| 104 | +Don't hesitate to create a pull request. Every contribution is appreciated. |
| 105 | + |
| 106 | +## [Changelog](CHANGELOG.md) |
| 107 | + |
| 108 | +## [License](LICENSE.md) |
0 commit comments