svg-sprite-generation-loader 0.0.1 → 0.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/.github/dependabot.yml +11 -0
- package/README.md +60 -12
- package/package.json +2 -2
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
|
3
|
+
# Please see the documentation for all configuration options:
|
|
4
|
+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
5
|
+
|
|
6
|
+
version: 2
|
|
7
|
+
updates:
|
|
8
|
+
- package-ecosystem: "npm" # See documentation for possible values
|
|
9
|
+
directory: "/" # Location of package manifests
|
|
10
|
+
schedule:
|
|
11
|
+
interval: "daily"
|
package/README.md
CHANGED
|
@@ -3,7 +3,50 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/svg-sprite-generation-loader)
|
|
4
4
|
[](https://github.com/vadymshymko/svg-sprite-generation-loader/blob/master/LICENSE)
|
|
5
5
|
|
|
6
|
-
Webpack
|
|
6
|
+
Webpack loader for generating external svg symbol sprite files
|
|
7
|
+
|
|
8
|
+
## How it works?
|
|
9
|
+
|
|
10
|
+
svg-sprite-generation-loader is a webpack-loader that takes a multiple svg files, transform them, optimizes and put them back in one file.
|
|
11
|
+
|
|
12
|
+
Input multiple svg files, e.g:
|
|
13
|
+
|
|
14
|
+
```html
|
|
15
|
+
<!-- file1.svg -->
|
|
16
|
+
<svg viewBox="0 0 10 10">
|
|
17
|
+
<!-- file1.svg content -->
|
|
18
|
+
</svg>
|
|
19
|
+
|
|
20
|
+
<!-- file2.svg -->
|
|
21
|
+
<svg viewBox="0 0 10 30">
|
|
22
|
+
<!-- file2.svg content -->
|
|
23
|
+
</svg>
|
|
24
|
+
|
|
25
|
+
<!-- file3.svg -->
|
|
26
|
+
<svg viewBox="0 0 15 40">
|
|
27
|
+
<!-- file3.svg content -->
|
|
28
|
+
</svg>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Output one svg file (svg sprite):
|
|
32
|
+
|
|
33
|
+
```html
|
|
34
|
+
<svg xmlns="http://www.w3.org/2000/svg">
|
|
35
|
+
<symbol viewBox="0 0 10 10" id="file1">
|
|
36
|
+
<!-- file1.svg content -->
|
|
37
|
+
</symbol>
|
|
38
|
+
|
|
39
|
+
<symbol viewBox="0 0 10 30" id="file2">
|
|
40
|
+
<!-- file1.svg content -->
|
|
41
|
+
</symbol>
|
|
42
|
+
|
|
43
|
+
<symbol viewBox="0 0 15 40" id="file3">
|
|
44
|
+
<!-- file3.svg content -->
|
|
45
|
+
</symbol>
|
|
46
|
+
</svg>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
You can refer to this file to display all your icons using [SVG stacking technique](https://css-tricks.com/svg-fragment-identifiers-work/#article-header-id-4)
|
|
7
50
|
|
|
8
51
|
## Installation:
|
|
9
52
|
|
|
@@ -17,6 +60,15 @@ npm install svg-sprite-generation-loader --save-dev
|
|
|
17
60
|
yarn add svg-sprite-generation-loader --dev
|
|
18
61
|
```
|
|
19
62
|
|
|
63
|
+
## Options
|
|
64
|
+
|
|
65
|
+
Plugin options:
|
|
66
|
+
|
|
67
|
+
| Name | Type | Default value | Description |
|
|
68
|
+
| -------------- | -------- | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------- |
|
|
69
|
+
| spriteFilePath | `string` | `sprite.svg` | Path to sprite file.<br /> `webpack.output.path` <br /> is included |
|
|
70
|
+
| svgo | object | default preset with disabled `removeUselessDefs`, `removeViewBox` and `cleanupIDs` plugins | [svgo](https://github.com/svg/svgo) config object |
|
|
71
|
+
|
|
20
72
|
## Usage:
|
|
21
73
|
|
|
22
74
|
In your webpack config:
|
|
@@ -27,7 +79,7 @@ const SvgSpriteGenerationPlugin = require("svg-sprite-generation-loader/plugin.j
|
|
|
27
79
|
module.exports = {
|
|
28
80
|
plugins: [
|
|
29
81
|
new SvgSpriteGenerationPlugin.Plugin({
|
|
30
|
-
spriteFilePath:
|
|
82
|
+
spriteFilePath: "path/to/sprite/filename.svg",
|
|
31
83
|
}),
|
|
32
84
|
],
|
|
33
85
|
module: {
|
|
@@ -43,14 +95,10 @@ module.exports = {
|
|
|
43
95
|
|
|
44
96
|
In some source code:
|
|
45
97
|
|
|
46
|
-
```
|
|
47
|
-
import
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
<use href="path/to/sprite/file.svg#iconFileName">
|
|
53
|
-
</svg>
|
|
54
|
-
);
|
|
55
|
-
}
|
|
98
|
+
```jsx
|
|
99
|
+
import iconAttributes from "path/to/some/icon-file-name.svg";
|
|
100
|
+
|
|
101
|
+
<svg {...iconAttributes}>
|
|
102
|
+
<use href="path/to/sprite/filename.svg#icon-file-name" />
|
|
103
|
+
</svg>;
|
|
56
104
|
```
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svg-sprite-generation-loader",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Webpack loader for generating svg
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Webpack loader for generating external svg symbol sprite files",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1"
|