Skip to content

Commit 42e3dc9

Browse files
authored
Create README.md
1 parent 91027f6 commit 42e3dc9

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

README.md

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# `svelte-svg-loader`
2+
3+
Webpack loader to transform SVGs into Svelte components.
4+
5+
It also optimizes your SVGs by running them thru
6+
[svgo](https://github.com/svg/svgo).
7+
8+
## Note
9+
10+
This package is not published to NPM at this point in time.
11+
12+
## Usage
13+
14+
```svelte
15+
<script>
16+
import MyIcon from 'assets/my-icon.svg';
17+
</script>
18+
19+
<MyIcon width={42} height={42} />
20+
```
21+
22+
## Setup
23+
24+
### `webpack.config.js`
25+
26+
```js
27+
module.exports = {
28+
//...
29+
module: {
30+
rules: [
31+
{
32+
test: /\.svg$/,
33+
use: [
34+
{
35+
loader: 'svelte-svg-loader',
36+
options: {
37+
svgoConfig: {},
38+
ssr: false,
39+
},
40+
},
41+
],
42+
},
43+
],
44+
},
45+
};
46+
```
47+
48+
Note: If you are amending an existing Webpack config, make sure to remove the default loader for assets (which includes svgs), or place `svelte-svg-loader` before it in the loaders array.
49+
```js
50+
// Remove default SVG loader
51+
config.module.rules = config.module.rules.filter(l => l.test && !l.test.toString().includes('svg'));
52+
```
53+
54+
## Credits
55+
56+
This plugin is based on the work from the following projects:
57+
58+
- https://github.com/metafy-gg/rollup-plugin-svelte-svg
59+
- https://github.com/metafy-gg/vite-plugin-svelte-svg
60+
- https://github.com/codefeathers/rollup-plugin-svelte-svg
61+
- https://github.com/visualfanatic/vite-svg
62+
63+
## License
64+
65+
MIT

0 commit comments

Comments
 (0)