From ae2b6797008d3defdfac6d1e5444cd9df0f68aa2 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sat, 29 Jul 2023 13:54:39 -0400 Subject: [PATCH] feat: add support for vite define --- src/index.ts | 2 ++ templates/vite.config.js | 1 + 2 files changed, 3 insertions(+) diff --git a/src/index.ts b/src/index.ts index ebbf440..b024580 100644 --- a/src/index.ts +++ b/src/index.ts @@ -32,12 +32,14 @@ function buildOptions(context: PresetContext) { throw new Error("vite options missing!"); } + const define = opts.define; const build = opts.build; const resolve = opts.resolve; const optimize = opts.optimize; const polyfill = opts.polyfill; return { + viteDefine: resolveDirective(define, context).stringifiedConfig, viteBuild: resolveDirective(build, context).stringifiedConfig, viteResolve: resolveDirective(resolve, context).stringifiedConfig, viteOptimize: resolveDirective(optimize, context).stringifiedConfig, diff --git a/templates/vite.config.js b/templates/vite.config.js index fecbc96..474d1bb 100644 --- a/templates/vite.config.js +++ b/templates/vite.config.js @@ -2,6 +2,7 @@ import { defineConfig } from "vite"; import optimizer from "vite-plugin-optimizer"; import { nodePolyfills } from "vite-plugin-node-polyfills"; export default defineConfig({ + define: {viteDefine}, build: {viteBuild}, resolve: {viteResolve}, plugins: [