Skip to content

Commit

Permalink
feat: expose file-loader publicPath
Browse files Browse the repository at this point in the history
  • Loading branch information
jubeiam committed Sep 24, 2019
1 parent 4bd1f8e commit 88ee0e3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ Sprites help increase speed, maintain a consistent development workflow, and mak

**Demo**: https://codesandbox.io/s/github/nuxt-community/svg-sprite-module/

:warning: **NOTE**: SVG Sprites does not work on IE, if you wish to support IE you could use [svg4everybody](https://github.com/jonathantneal/svg4everybody). Take a look at [this issue](https://github.com/nuxt-community/svg-sprite-module/issues/42#issuecomment-516056532) to see how.
:warning: **NOTE**: SVG Sprites does not work on IE, if you wish to support IE you could use [svg4everybody](https://github.com/jonathantneal/svg4everybody). Take a look at [this issue](https://github.com/nuxt-community/svg-sprite-module/issues/42#issuecomment-516056532) to see how.

:rainbow: **NOTE**: If you wish to load single SVG icon and you don't want to create sprites, use [Nuxt SVG Module](https://github.com/nuxt-community/svg-module). SVG module for Nuxt.js, allows you to import .svg files in multiple ways depending on the resource query you provide.
:rainbow: **NOTE**: If you wish to load single SVG icon and you don't want to create sprites, use [Nuxt SVG Module](https://github.com/nuxt-community/svg-module). SVG module for Nuxt.js, allows you to import .svg files in multiple ways depending on the resource query you provide.

## Installation

Expand Down Expand Up @@ -60,6 +60,7 @@ Module default options:
| defaultSprite | `icons` | Name of default sprite (default sprite consist of all svgs that place directly inside `input` directory) |
| elementClass | `icon` | global class of all `<svg-icon>` instances |
| spriteClassPrefix | `sprite-` | Prefix of sprite specific classes |
| publicPath | `null` | Specifies a custom public path for the sprites |

You can update them with the `svgSprite` option in `nuxt.config.js`:

Expand Down Expand Up @@ -92,5 +93,5 @@ You can also contribute directly with CodeSandBox: https://codesandbox.io/s/gith

## License

[MIT License](./LICENSE)
[MIT License](./LICENSE)
Copyright (c) Nuxt Community - Ahad Birang
8 changes: 7 additions & 1 deletion lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,19 @@ function extendBuild (config, options) {
}
})

const fileLoaderOptions = {}
if (options.publicPath) {
fileLoaderOptions.publicPath = options.publicPath
}

// add file-loader only to sprite output folder
config.module.rules.push({
test: /\.svg$/,
include: [path.resolve(options.output)],
use: [
{
loader: 'file-loader'
loader: 'file-loader',
options: fileLoaderOptions
}
]
})
Expand Down

0 comments on commit 88ee0e3

Please sign in to comment.