Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: nuxt-community/svg-module
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.4.0
Choose a base ref
...
head repository: nuxt-community/svg-module
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.4.1
Choose a head ref
  • 3 commits
  • 4 files changed
  • 4 contributors

Commits on Jul 13, 2022

  1. Adds example for dynamic SVG without wrapper to README (#91)

    * Adds dynamic SVG without wrapper to README
    
    See #72 for context.
    
    * fix(README): typo
    
    Co-authored-by: Manuel Odelain <hello@manuelodelain.com>
    madc and manuelodelain authored Jul 13, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2e8f33b View commit details

Commits on Sep 4, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    99658e7 View commit details
  2. 0.4.1

    manuelodelain committed Sep 4, 2023
    Copy the full SHA
    7d8beab View commit details
Showing with 24 additions and 5 deletions.
  1. +18 −0 README.md
  2. +4 −3 lib/module.js
  3. +1 −1 package-lock.json
  4. +1 −1 package.json
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -194,6 +194,24 @@ To dynamically import an SVG, you can use the inline `require()` syntax.

> This example uses `raw-loader`.
To render an SVG without wrapper element and the use of `v-html`, a combination of [dynamic components](https://vuejs.org/guide/essentials/component-basics.html#dynamic-components) and `?inline` can be used. See #72 for context.

```html
<template>
<component :is="require(`../assets/${name}.svg?inline`)" />
</template>

<script>
export default {
props: {
name: { type: String, default: "image" },
},
};
</script>
```

> This example uses `vue-svg-loader`.
## Caveats

In order for this module to work correctly, the [default `.svg` Nuxt.js webpack rule](https://nuxtjs.org/guide/assets/#webpack) gets replaced with this handler.
7 changes: 4 additions & 3 deletions lib/module.js
Original file line number Diff line number Diff line change
@@ -20,13 +20,14 @@ export default function svgModule(moduleOptions) {
*
* @param options The module options
* @param config The webpack configuration object to extend
* @param context Nuxt webpack env
*/
function setup(options, config) {
function setup(options, config, context) {
const fileLoaderOptions = Object.assign(
{},
getFileLoaderDefaultConfig(this),
getFileLoaderDefaultConfig(context),
typeof options.fileLoader === "function"
? options.fileLoader(this)
? options.fileLoader(context)
: options.fileLoader
);

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nuxtjs/svg",
"version": "0.4.0",
"version": "0.4.1",
"description": "Super simple svg loading module for Nuxt.js",
"keywords": [
"nuxt",