├── .gitignore
├── IconComponent.vue
├── LICENSE
├── README.md
├── index.js
└── package.json
/.gitignore:
--------------------------------------------------------------------------------
1 | vendor
2 | node_modules
3 | package-lock.json
--------------------------------------------------------------------------------
/IconComponent.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
20 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2018 Excellent Ingenuity LLC & James Johnson
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # laravel-mix-vue-svgicon
2 |
3 | Laravel Mix extension that provides loading svgs as a vue component named icon, compatible with Adam Wathan's Blade extension. This package is inspired by the post by Caleb Porzio - [Using inline SVGs in Vue components.](http://calebporzio.com/using-inline-svgs-in-vue-compoments/)
4 |
5 | ## Installation
6 | `npm install laravel-mix-vue-svgicon`
7 |
8 | ## Setup
9 | In your `webpack.mix.js` to the top of the file, add: `require('laravel-mix-vue-svgicon');` .
10 |
11 | Then in your `mix` method chain add: `.svgicon('your path here')`.
12 |
13 | If you do not provide a path to the method, the default path is `./../public/resources/svg` to provide compatability with [Adam Wathan's Blade SVG package.](https://github.com/adamwathan/blade-svg)
14 |
15 | **Note the path that** `.svgicon()` **takes is relative to the root directory where your webpack.mix.js file resides. If your path is incorrect then the extension will not work and webpack will throw an error that it cannot load the module `SVGPATH`.**
16 |
17 | ## Usage
18 |
19 | ### Default
20 |
21 | Once you have the package installed and the mix extension active you may use the icon component like anyother vue.js component. The sole property that the component takes is the name of the file under the svg directory you provided to the mix method. E.g., file is `resources/svg/close.svg`, `webpack.mix.js` includes `mix.svgicon(resources/svg)` and the consuming vue component looks like this:
22 |
23 | ```javascript
24 |
25 |
26 |
29 |
30 |
31 |
55 | ```
56 | ### Additional Child Directories
57 |
58 | Additionally, nested folders of svg's under the svg root directory provided to the mix method can be accessed by simply giving the component the relative path & file name, minus the file extension. E.g., the `resources/svg` folder contains a folder `zondicons`.
59 |
60 | ```javascript
61 |
62 |