svg-sprite-generation-loader 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,6 +5,13 @@
|
|
|
5
5
|
|
|
6
6
|
Webpack loader for generating external svg symbol sprite files
|
|
7
7
|
|
|
8
|
+
## Table of contents
|
|
9
|
+
|
|
10
|
+
- [How it works?](#how-it-works)
|
|
11
|
+
- [Installation](#installation)
|
|
12
|
+
- [Usage](#usage)
|
|
13
|
+
- [Options](#options)
|
|
14
|
+
|
|
8
15
|
## How it works?
|
|
9
16
|
|
|
10
17
|
svg-sprite-generation-loader is a webpack-loader that takes a multiple svg files, optimize them (using [svgo.optimize](https://github.com/svg/svgo#optimize)), transform (parse and return as an object with `symbolId`, `attributes` and `content` (disabled by default) keys) and put them back in one file.
|
|
@@ -60,15 +67,6 @@ npm install svg-sprite-generation-loader --save-dev
|
|
|
60
67
|
yarn add svg-sprite-generation-loader --dev
|
|
61
68
|
```
|
|
62
69
|
|
|
63
|
-
## Options
|
|
64
|
-
|
|
65
|
-
| Name | Type | Default value | Description |
|
|
66
|
-
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
67
|
-
| symbolId | `string` \| `function(iconPath)` - function that takes the file path of the original icon as an argument and returns the symbolId value<br /> In both cases you can use [interpolateName](https://github.com/webpack/loader-utils#interpolatename) patterns | `"[name]"` which is equal to icon filename (without extension). For example, by default symbolId for `file1.svg` file will be `file1` | `<symbol>` `id` attribute value. |
|
|
68
|
-
| spriteFilePath | `string` | `sprite.svg` | Path to sprite file.<br /> `webpack.output.path` <br /> is included |
|
|
69
|
-
| svgoOptimize | `boolean` \| `object` | `true` | Enable/Disable/Customize source svg file optimization with [svgo.optimize](https://github.com/svg/svgo#optimize). The following options are used by default: <br /><pre>`{`<br /> `plugins: [`<br /> `{`<br /> `name: 'preset-default',`<br /> `params: {`<br /> `overrides: {`<br /> `removeViewBox: false,`<br /> `},`<br /> `},`<br /> `},`<br /> `'removeXMLNS',`<br /> `],`<br />`}`</pre> You can disable it completely (by passing `false`) or use your own configuration (see [svgo docs](https://github.com/svg/svgo#optimize)) |
|
|
70
|
-
| addContent | `boolean` | `false` | Add svg content as property to transformed svg object (may increase bundle size when enabled) |
|
|
71
|
-
|
|
72
70
|
## Usage:
|
|
73
71
|
|
|
74
72
|
In your webpack config:
|
|
@@ -77,7 +75,7 @@ In your webpack config:
|
|
|
77
75
|
const SvgSpriteGenerationPlugin = require('svg-sprite-generation-loader/plugin.js');
|
|
78
76
|
|
|
79
77
|
module.exports = {
|
|
80
|
-
plugins: [new SvgSpriteGenerationPlugin
|
|
78
|
+
plugins: [new SvgSpriteGenerationPlugin()],
|
|
81
79
|
module: {
|
|
82
80
|
rules: [
|
|
83
81
|
{
|
|
@@ -101,3 +99,12 @@ import iconData from 'path/to/some/icon-file-name.svg';
|
|
|
101
99
|
<use href={`path/to/sprite/filename.svg#${iconData.symbolId}`} />
|
|
102
100
|
</svg>;
|
|
103
101
|
```
|
|
102
|
+
|
|
103
|
+
## Options
|
|
104
|
+
|
|
105
|
+
| Name | Type | Default value | Description |
|
|
106
|
+
| -------------- | -------------------------------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
107
|
+
| symbolId | `string` \| `function` | `"[name]"` | Sprite item (single icon) `<symbol>` `id` attribute value.<br />`string` or `function` that takes the file path of the original icon as an argument and returns `string`.<br /><br />You can use [interpolateName](https://github.com/webpack/loader-utils#interpolatename) patterns.<br /> Default value (`"[name]"`) is equal to icon filename (without extension). For example, by default symbolId for `file1.svg` file will be `file1` |
|
|
108
|
+
| spriteFilePath | `string` | `sprite.svg` | Path to sprite file.<br /> `webpack.output.path` is included |
|
|
109
|
+
| svgoOptimize | `boolean` \| `object` | `true` | Enable/Disable/Customize source svg file optimization with [svgo.optimize](https://github.com/svg/svgo#optimize). The following options are used by default: <br /><pre>`{`<br /> `plugins: [`<br /> `{`<br /> `name: 'preset-default',`<br /> `params: {`<br /> `overrides: {`<br /> `removeViewBox: false,`<br /> `},`<br /> `},`<br /> `},`<br /> `'removeXMLNS',`<br /> `],`<br />`}`</pre> You can disable it completely (by passing `false`) or use your own configuration (see [svgo docs](https://github.com/svg/svgo#optimize)) |
|
|
110
|
+
| **addContent** | `boolean` | `false` | Add svg content as property to transformed svg object (may increase bundle size when enabled) |
|