npm install ant-design-vue --save
安装插件
npm install unplugin-vue-components -D
安装less
npm install less -D
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import styleImport, { VantResolve } from "vite-plugin-style-import";
import Components from 'unplugin-vue-components/vite';
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
import path from 'path'
// https://vitejs.dev/config/
export default defineConfig({
server:{
port: 8080,
},
//设置别名
resolve: {
alias: {
'@': path.resolve(__dirname,'./src'),
'comps': path.resolve(__dirname,'./src/components')
}
},
plugins: [
vue(),
styleImport({
resolves: [VantResolve()],
}),
Components({
resolvers: [AntDesignVueResolver()],
}),
],
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
}
}
},
});
开启less Js运行时
通常未开启时是不能在js中导入less的
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
// modifyVars: {
// 'primary-color': '#20C456'
// }
}
}
},