vitejs / vite-plugin-vue

Vite Vue Plugins
MIT License
478 stars 152 forks source link

No loader is configured for ".vue" #26

Closed jaune001 closed 1 week ago

jaune001 commented 2 years ago

Describe the bug

after the import component library, prompt error,

error message: image

@xx/up-ui is independent research and development components

    {
  "name": "vite-vue2",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vite",
    "build": "vite build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "@xx/up-ui": "^2.1.81",
    "core-js": "^3.6.5",
    "path": "^0.12.7",
    "vite": "^2.3.7",
    "vite-plugin-vue2": "^1.6.2",
    "vue": "^2.6.11",
    "vue-router": "^3.2.0",
    "vuex": "^3.4.0"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "~4.5.0",
    "@vue/cli-plugin-eslint": "~4.5.0",
    "@vue/cli-plugin-router": "~4.5.0",
    "@vue/cli-plugin-vuex": "~4.5.0",
    "@vue/cli-service": "~4.5.0",
    "@vue/eslint-config-prettier": "^6.0.0",
    "babel-eslint": "^10.1.0",
    "eslint": "^6.7.2",
    "eslint-plugin-prettier": "^3.3.1",
    "eslint-plugin-vue": "^6.2.2",
    "less": "^3.0.4",
    "less-loader": "^5.0.0",
    "prettier": "^2.2.1",
    "vue-template-compiler": "^2.6.11"
  }
}

Reproduction

https://github.com/WongYuYe/vite-vue2-demo

vite-vue2-demo import @xx/up-ui components

@xx/up-ui is research and development of internal component library

@xx/up-ui vue: 2.xx

System Info

MacBook Pro (13-inch, 2020, Four Thunderbolt 3 ports)

node: v14.17.5
npm: 6.14.14

Used Package Manager

npm

Logs

npm run serve

Validations

Shinigami92 commented 2 years ago

I assume this is not a problem of vite itself but you try to use a combination of vue-cli and vite together :thinking:

bluwy commented 2 years ago

This is because vue-pdf exports the raw Vue file, which esbuild can't handle unless there's a esbuild plugin that handles Vue files. Until plugin-vue supports something like https://github.com/vitejs/vite/pull/6801 (experimental), vue-pdf should be publishing compiled JS files. Another workaround is to optimizeDeps.exclude: ["vue-pdf"] so that the Vue files are processed by the Vite dev server. Its transitive deps may need to be re-included (docs).

Related: https://github.com/FranckFreiburger/vue-pdf/issues/304

edison1105 commented 1 week ago

It seems not related to vite-plugin-vue. try https://github.com/vitejs/vite-plugin-vue2