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

启动项目报错,提示not a function #2

Open
CoffeeSwt opened this issue Apr 28, 2023 · 1 comment
Open

启动项目报错,提示not a function #2

CoffeeSwt opened this issue Apr 28, 2023 · 1 comment

Comments

@CoffeeSwt
Copy link

错误信息

S E:\project\cesiumosgb> yarn dev
yarn run v1.22.19
$ vite
failed to load config from E:\project\cesiumosgb\vite.config.ts
error when starting dev server:
TypeError: CopyPlugin is not a function
    at file:///E:/project/cesiumosgb/vite.config.ts.timestamp-1682657826482-cbc776d5aa0aa.mjs:35:5
    at ModuleJob.run (node:internal/modules/esm/module_job:197:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:337:24)
    at async loadConfigFromBundledFile (file:///E:/project/cesiumosgb/node_modules/vite/dist/node/chunks/dep-a178814b.js:64414:21)
    at async loadConfigFromFile (file:///E:/project/cesiumosgb/node_modules/vite/dist/node/chunks/dep-a178814b.js:64296:28)
    at async resolveConfig (file:///E:/project/cesiumosgb/node_modules/vite/dist/node/chunks/dep-a178814b.js:63904:28)
    at async _createServer (file:///E:/project/cesiumosgb/node_modules/vite/dist/node/chunks/dep-a178814b.js:63190:20)
    at async CAC.<anonymous> (file:///E:/project/cesiumosgb/node_modules/vite/dist/node/cli.js:733:24)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

我的代码

import path, { resolve } from "path";
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
import Inspect from "vite-plugin-inspect";
//vite-plugin-inspect(插件调试工具)
//它可以帮助你检查 Vite 插件的中间状态。安装后,你可以访问localhost:3000/__inspect/来检查你项目的模块和栈信息。请查阅vite-plugin-inspect 文档中的安装说明。
import cesium from "vite-plugin-cesium"; // 引入插件
const dvgisDist = "./node_modules/@dvgis";
import CopyPlugin from "vite-plugin-files-copy";

// https://vitejs.dev/config/
export default defineConfig({
  server: {
    proxy: {
      "/api": {
        target: "http://localhost:8888", // 实际请求地址
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ""),
      },
    },
  },
  plugins: [
    vue(),
    AutoImport({
      imports: ["vue"],
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
    Inspect(),
    cesium(),
    CopyPlugin({
      patterns: [
        {
          from: path.join(dvgisDist, "dc-sdk/dist/resources"), // string 相对项目下相对路径
          to: "libs/dc-sdk/resources", // string 相对项目下相对路径
        },
      ],
    }),
  ],
  resolve: {
    alias: [{ find: "@", replacement: resolve(__dirname, "./src") }],
  },
});
@CoffeeSwt
Copy link
Author

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

1 participant