Skip to content

Commit d2d521d

Browse files
committed
Docs
1 parent 04dabc6 commit d2d521d

File tree

11 files changed

+547
-2
lines changed

11 files changed

+547
-2
lines changed

docs/.vuepress/Example.vue

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<template>
2+
<nav>
3+
<a href="#" class="btn btn-vue">
4+
<VueLogo class="icon" />
5+
Vue
6+
</a>
7+
<a href="#" class="btn btn-svgo">
8+
<SVGOIcon class="icon" />
9+
SVGO
10+
</a>
11+
<a href="#" class="btn btn-webpack">
12+
<WebpackIcon class="icon" />
13+
webpack
14+
</a>
15+
</nav>
16+
</template>
17+
<script>
18+
import VueLogo from './public/vue.svg';
19+
import SVGOIcon from './public/svgo.svg';
20+
import WebpackIcon from './public/webpack.svg';
21+
22+
export default {
23+
name: 'Example',
24+
components: {
25+
VueLogo,
26+
SVGOIcon,
27+
WebpackIcon,
28+
},
29+
};
30+
</script>
31+
<style scoped>
32+
.btn {
33+
display: inline-flex;
34+
align-items: center;
35+
margin-right: 10px;
36+
padding: 6px 10px;
37+
border-radius: 6px;
38+
border: 2px solid currentColor;
39+
}
40+
41+
.btn-vue { color: #4fc08d; }
42+
.btn-svgo { color: #2364c0; }
43+
.btn-webpack { color: #1d78c1; }
44+
45+
.icon {
46+
width: 28px;
47+
height: 28px;
48+
margin-right: 10px;
49+
}
50+
</style>

docs/.vuepress/config.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = {
2+
title: 'Documentation',
3+
chainWebpack: (config) => {
4+
const svgRule = config.module.rule('svg');
5+
6+
svgRule.uses.clear();
7+
8+
svgRule
9+
.use('vue-svg-loader')
10+
.loader(require.resolve('../../index'));
11+
},
12+
themeConfig: {
13+
repo: 'visualfanatic/vue-svg-loader',
14+
editLinks: true,
15+
nav: [
16+
{
17+
text: 'FAQ',
18+
link: '/faq',
19+
},
20+
],
21+
},
22+
};

docs/.vuepress/enhanceApp.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Tabs, Tab } from 'vue-tabs-component';
2+
import Logo from './public/logo.svg';
3+
import Example from './Example';
4+
5+
export default ({
6+
Vue,
7+
}) => {
8+
Vue.component('Tabs', Tabs);
9+
Vue.component('Tab', Tab);
10+
Vue.component('Logo', Logo);
11+
Vue.component('Example', Example);
12+
};

docs/.vuepress/public/logo.svg

Lines changed: 1 addition & 0 deletions
Loading

docs/.vuepress/public/svgo.svg

Lines changed: 1 addition & 0 deletions
Loading

docs/.vuepress/public/vue.svg

Lines changed: 1 addition & 0 deletions
Loading

docs/.vuepress/public/webpack.svg

Lines changed: 1 addition & 0 deletions
Loading

docs/.vuepress/style.styl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
@import '~@default-theme/styles/config.styl'
2+
3+
.home .hero img
4+
max-height 140px
5+
6+
.tabs-component-tabs
7+
list-style none
8+
display flex
9+
padding-left 0
10+
11+
.tabs-component-tab
12+
margin-right 25px
13+
14+
.tabs-component-tab-a
15+
color desaturate(lighten($textColor, 45%), 10%)
16+
17+
.tabs-component-tab.is-active
18+
.tabs-component-tab-a
19+
color $accentColor
20+
21+
.tabs-component-panels
22+
margin-bottom 40px

docs/README.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
home: true
3+
heroText: vue-svg-loader
4+
heroImage: /logo.svg
5+
actionText: Example →
6+
tagline: Use SVG files as Vue components
7+
actionLink: /#example
8+
features:
9+
- title: Easily styleable
10+
details: This loader inlines the SVGs which enables you to style aspects like for example stroke/fill color.
11+
- title: Optimized
12+
details: Each SVG you import is optimized on-the-fly using powerful SVGO without you having to do anything.
13+
- title: SSR ready
14+
details: You can import the SVG components inside the code that is going to be rendered on the server side.
15+
---
16+
17+
## Installation
18+
19+
<Tabs>
20+
<Tab name="yarn">
21+
22+
``` bash
23+
yarn add -D vue-svg-loader
24+
```
25+
26+
</Tab>
27+
<Tab name="npm">
28+
29+
``` bash
30+
npm i -D vue-svg-loader
31+
```
32+
33+
</Tab>
34+
</Tabs>
35+
36+
## Configuration
37+
38+
<Tabs>
39+
<Tab name="webpack">
40+
41+
::: warning
42+
Make sure that your current configuration is not already processing the SVG files.
43+
Check this [FAQ](/faq#how-to-use-both-inline-and-external-svgs) section if you want to use both inline and external SVGs.
44+
:::
45+
46+
``` js
47+
module.exports = {
48+
module: {
49+
rules: [
50+
{
51+
test: /\.svg$/,
52+
loader: 'vue-svg-loader',
53+
},
54+
],
55+
},
56+
};
57+
```
58+
59+
</Tab>
60+
<Tab name="Vue CLI">
61+
62+
By default Vue CLI uses the `file-loader` to process the SVG files, you can replace it in `vue.config.js`:
63+
64+
``` js
65+
module.exports = {
66+
chainWebpack: (config) => {
67+
const svgRule = config.module.rule('svg');
68+
69+
svgRule.uses.clear();
70+
71+
svgRule
72+
.use('vue-svg-loader')
73+
.loader('vue-svg-loader');
74+
},
75+
};
76+
```
77+
78+
</Tab>
79+
<Tab name="Nuxt.js">
80+
81+
Similarly to Vue CLI, you need to modify existing rule (in `nuxt.config.js`) that processes the SVG files:
82+
83+
``` js
84+
module.exports = {
85+
build: {
86+
extend: (config) => {
87+
const svgRule = config.module.rules.find(rule => rule.loader === 'url-loader');
88+
89+
svgRule.test = /\.(png|jpe?g|gif)$/;
90+
91+
config.module.rules.push({
92+
test: /\.svg$/,
93+
loader: 'vue-svg-loader',
94+
});
95+
},
96+
},
97+
};
98+
```
99+
100+
</Tab>
101+
</Tabs>
102+
103+
## Example
104+
105+
### Preview
106+
107+
<Example />
108+
109+
### Code
110+
111+
<<< @/docs/.vuepress/Example.vue{4,8,12,18-20,25-27}

0 commit comments

Comments
 (0)