官网
为什么 Vite 加载速度快,webpack 做不到吗
创建应用
npm init @vitejs/app
or yarn create @vitejs/app
npm init @vitejs/app my-vue-app --template vue
npm 6+
npm init @vitejs/app my-vue-app -- --template vue
npm 7+
- 根据提示进入文件夹,
npm i
vite配置
import vue from "@vitejs/plugin-vue";
const { resolve } = require("path");
const NODE_ENV = process.env.NODE_ENV;
export default {
base: "/dist/",
plugins: [vue()],
alias: [{ find: "@", replacement: resolve(__dirname, "src") }],
build: {
assetsDir: "./static",
rollupOptions: {
input: {
main: resolve(__dirname, "index.html"),
nested: resolve(__dirname, 'xxxx.html')
},
},
},
server: {
proxy: {
"/api": {
target: "xxxx",
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, "/"),
},
},
},
};