From fc5c937d442dc908e9b7cb03d5f5aae89c712594 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Sun, 13 Mar 2022 03:50:50 +0800 Subject: [PATCH] fix: dont replace define in json (#7294) --- packages/playground/define/__tests__/define.spec.ts | 1 + packages/playground/define/data.json | 3 +++ packages/playground/define/index.html | 4 ++++ packages/vite/src/node/plugins/define.ts | 4 ++++ 4 files changed, 12 insertions(+) create mode 100644 packages/playground/define/data.json diff --git a/packages/playground/define/__tests__/define.spec.ts b/packages/playground/define/__tests__/define.spec.ts index 93ba1ca198fbcc..709f7a935dc8c1 100644 --- a/packages/playground/define/__tests__/define.spec.ts +++ b/packages/playground/define/__tests__/define.spec.ts @@ -22,4 +22,5 @@ test('string', async () => { ) // html would't need to define replacement expect(await page.textContent('.exp-define')).toBe('__EXP__') + expect(await page.textContent('.import-json')).toBe('__EXP__') }) diff --git a/packages/playground/define/data.json b/packages/playground/define/data.json new file mode 100644 index 00000000000000..491b781c2d97d3 --- /dev/null +++ b/packages/playground/define/data.json @@ -0,0 +1,3 @@ +{ + "foo": "__EXP__" +} diff --git a/packages/playground/define/index.html b/packages/playground/define/index.html index 4788ec9f2d2a57..da78d192216b11 100644 --- a/packages/playground/define/index.html +++ b/packages/playground/define/index.html @@ -10,6 +10,7 @@

Define

spread object:

spread array:

define variable in html: __EXP__

+

import json: