https://github.com/itgalaxy/figlet-loader
Get your figlet build bundled with Webpack
https://github.com/itgalaxy/figlet-loader
figlet loader webpack
Last synced: about 2 months ago
JSON representation
Get your figlet build bundled with Webpack
- Host: GitHub
- URL: https://github.com/itgalaxy/figlet-loader
- Owner: itgalaxy
- License: mit
- Created: 2016-09-01T13:03:58.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-04-17T11:08:42.000Z (over 2 years ago)
- Last Synced: 2025-10-07T11:16:36.156Z (3 months ago)
- Topics: figlet, loader, webpack
- Language: JavaScript
- Homepage:
- Size: 1.23 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 26
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# figlet-loader
[](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)
[](https://david-dm.org/itgalaxy/figlet-loader?type=peer)
[](https://greenkeeper.io)
Get your figlet build bundled with webpack.

## Install
```shell
$ npm install figlet-loader --save-dev
```
## Usage
[Documentation: Using loaders](http://webpack.github.io/docs/using-loaders.html)
There are three use case.
1. Using loader `options`.
**IMPORTANT**: add `type: "javascript/auto"` if you using `webpack@4` and `JSON` sytax for config.
```javascript
import content from "figlet"; // or `const content = require('figlet');`
console.log(content);
```
**webpack.config.js**
```javascript
module.exports = {
module: {
rules: [
{
loader: "figlet-loader",
// ONLY FOR `webpack@4` and `JSON` config
type: "javascript/auto",
options: {
fontOptions: {
// Full list of supported options and their description can be found in [figlet](https://github.com/patorjk/figlet.js).
font: "ANSI Shadow",
horizontalLayout: "default",
kerning: "default",
verticalLayout: "default"
},
textBefore: "TEXT BEFORE",
text: "ANOTHER-TEXT",
textAfter: "TEXT AFTER"
},
test: /empty-alias-file\.js$/
}
]
},
resolve: {
alias: {
// You can add comment "Please do not delete this file" in this file
figlet$: path.resolve(__dirname, "/path/to/empty-alias-file.js")
}
}
};
```
2. Using config file through alias (supported **JavaScript** and **JSON** syntax).
**IMPORTANT**: add `type: "javascript/auto"` if you using `webpack@4` and `JSON` sytax for config.
```javascript
import context from "figlet"; // or `const content = require('figlet');`
console.log(content);
```
**.figletrc.js**
```javascript
"use strict";
module.exports = {
fontOptions: {
font: "ANSI Shadow",
horizontalLayout: "default",
kerning: "default",
verticalLayout: "default"
},
textBefore: "TEXT BEFORE",
text: "ANOTHER-TEXT-JS-RC",
textAfter: "TEXT AFTER"
};
```
**webpack.config.js**
```javascript
module.exports = {
module: {
rules: [
{
loader: "figlet-loader",
// ONLY FOR `webpack@4` and `JSON` config
type: "javascript/auto",
test: /\.figletrc\.js$/
}
]
},
resolve: {
alias: {
figlet$: path.resolve(__dirname, "/path/to/.figletrc.js")
}
}
};
```
3. Using config (supported **JavaScript** and **JSON** syntax) file directly (see below example how it is use).
**IMPORTANT**: add `type: "javascript/auto"` if you using `webpack@4` and `JSON` sytax for config.
```javascript
import content from ".figletrc.js";
console.log(content);
```
**webpack.config.js**
```javascript
module.exports = {
module: {
rules: [
{
loader: "figlet-loader",
// ONLY FOR `webpack@4` and `JSON` config
type: "javascript/auto",
test: /\.figletrc\.js$/
}
]
}
};
```
## Additional Usage
Async loading:
1. Using `webpack` dynamic `import`.
```javascript
import("figlet").then(content => console.log(content));
```
2. You can used [bundle](https://github.com/webpack/bundle-loader) plugin for async loading:
```javascript
import figletLoader from "bundle?lazy!figlet";
figletLoader(content => console.log(content));
```
## Related
* [figlet](https://github.com/patorjk/figlet.js) - API for this module
## Contribution
Feel free to push your code if you agree with publishing under the MIT license.
## [Changelog](CHANGELOG.md)
## [License](LICENSE)