Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

svgSpritePlugin is not a function #11

Open
lionlimon opened this issue Oct 14, 2022 · 1 comment
Open

svgSpritePlugin is not a function #11

lionlimon opened this issue Oct 14, 2022 · 1 comment

Comments

@lionlimon
Copy link

lionlimon commented Oct 14, 2022

Hello, I have some problems with import. I get object instead of function

vite.config.ts

import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { resolve } from 'path';
import svgSpritePlugin from 'vite-plugin-svg-sprite-component';

console.log(svgSpritePlugin);

export default defineConfig({
  resolve: {
    alias: {
      '@': resolve(__dirname, 'src'),
    },
  },

  plugins: [
    vue(),
    svgSpritePlugin(),
  ],
});

package.json

{
  "name": "resume",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vue-tsc --noEmit && vite build",
    "lint:script": "eslint --ext .ts,vue --ignore-path .gitignore . --fix",
    "preview": "vite preview",
    "lint:style": "stylelint src/**/*.{css,scss,vue} --fix",
    "prepare": "husky install"
  },
  "dependencies": {
    "normalize.css": "^8.0.1",
    "vue": "^3.2.37"
  },
  "devDependencies": {
    "@types/node": "^18.8.3",
    "@typescript-eslint/eslint-plugin": "^5.39.0",
    "@vitejs/plugin-vue": "^3.1.0",
    "@vue/eslint-config-typescript": "^11.0.2",
    "eslint": "^8.25.0",
    "eslint-config-airbnb-base": "^15.0.0",
    "eslint-import-resolver-alias": "^1.1.2",
    "eslint-import-resolver-typescript": "^3.5.1",
    "eslint-plugin-import": "^2.26.0",
    "eslint-plugin-vue": "^9.6.0",
    "husky": "^8.0.0",
    "postcss-html": "^1.5.0",
    "sass": "^1.55.0",
    "stylelint": "^14.13.0",
    "stylelint-config-recommended-scss": "^7.0.0",
    "stylelint-config-recommended-vue": "^1.4.0",
    "stylelint-config-standard-scss": "^5.0.0",
    "typescript": "^4.6.4",
    "vite": "^3.1.0",
    "vite-plugin-svg-sprite-component": "^1.0.10",
    "vue-tsc": "^0.40.4"
  }
}

node version: 16, 18

console.log output { default: [Function: createPlugin] }

full error:

failed to load config from /Users/levkaplunov/Desktop/projects/Resume/vite.config.ts
error when starting dev server:
TypeError: svgSpritePlugin is not a function
    at file:///Users/levkaplunov/Desktop/projects/Resume/vite.config.ts.timestamp-1665731229538.mjs:16:5
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
    at async loadConfigFromBundledFile (file:///Users/levkaplunov/Desktop/projects/Resume/node_modules/vite/dist/node/chunks/dep-db16f19c.js:63505:21)
    at async loadConfigFromFile (file:///Users/levkaplunov/Desktop/projects/Resume/node_modules/vite/dist/node/chunks/dep-db16f19c.js:63400:28)
    at async resolveConfig (file:///Users/levkaplunov/Desktop/projects/Resume/node_modules/vite/dist/node/chunks/dep-db16f19c.js:63017:28)
    at async createServer (file:///Users/levkaplunov/Desktop/projects/Resume/node_modules/vite/dist/node/chunks/dep-db16f19c.js:62083:20)
    at async CAC.<anonymous> (file:///Users/levkaplunov/Desktop/projects/Resume/node_modules/vite/dist/node/cli.js:700:24)
error Command failed with exit code 1.

@cereschen
Copy link
Owner

I don't know why this happens, but you can modify it as follows:
import { default as svgSpritePlugin } from 'vite-plugin-svg-sprite-component'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants