安装unplugin-icons以及 @element-plus/icons-vue和 unplugin-auto-import
接下来配置如下
const { defineConfig } = require("@vue/cli-service");
const AutoImport = require("unplugin-auto-import/webpack");
const Components = require("unplugin-vue-components/webpack");
const { ElementPlusResolver } = require("unplugin-vue-components/resolvers");
const Icons = require('unplugin-icons/webpack')
const IconsResolver = require('unplugin-icons/resolver')
module.exports = defineConfig({
transpileDependencies: true,
configureWebpack: {
plugins: [
AutoImport({
resolvers: [
ElementPlusResolver(),
IconsResolver({
prefix: "Icon",
}),
],
}),
Components({
resolvers: [
IconsResolver({
enabledCollections: ["ep"],
}),
ElementPlusResolver(),
],
}),
Icons({
autoInstall: true,
}),
],
},
});