# vite-plugin-env-main **Repository Path**: phoooob/vite-plugin-env-main ## Basic Information - **Project Name**: vite-plugin-env-main - **Description**: 根据环境不同,区分不同的入口文件。默认入口文件为`/src/main.js`,开发环境入口文件为`/src/main.dev.js`。 比如你想在开发阶段全量引入element-plus,在生产环境中按需引入,此时需要编写不同的入口文件。 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-02-26 - **Last Updated**: 2022-02-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 插件用途 根据环境不同,区分不同的入口文件。默认入口文件为`/src/main.js`,开发环境入口文件为`/src/main.dev.js`。 比如你想在开发阶段全量引入element-plus,在生产环境中按需引入,此时需要编写不同的入口文件。 ## 安装插件 Install the plugin with npm: ``` npm install vite-plugin-env-main --save-dev ``` or yarn ``` yarn add vite-plugin-env-main -D ``` ## 基本用法 在 vite.config.js 中配置插件: ```js // vite.config.js import CreateEnvMain from "vite-plugin-env-main"; export default { plugins: [ CreateEnvMain() ], } ``` ## 实现原理 插件的基本原理是在开发环境下,自动将`index.html`中的`/src/main.js`替换为`/src/main.dev.js`。所以你需要保证在`index.html`中,有如下默认代码: ```html // index.html ```