Skip to content

Commit c0036e6

Browse files
committed
build: fix code replace
1 parent 529b675 commit c0036e6

File tree

5 files changed

+20
-45
lines changed

5 files changed

+20
-45
lines changed

pnpm-lock.yaml

Lines changed: 0 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/e2e/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
"react-router": "^7.3.0",
4040
"react-transition-group": "^4.4.5",
4141
"tsx": "^4.19.3",
42-
"vite": "^6.2.2",
43-
"vite-plugin-replace": "^0.1.1"
42+
"vite": "^6.2.2"
4443
}
4544
}

test/e2e/vite.config.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
import { defineConfig } from 'vite';
22
import react from '@vitejs/plugin-react';
3-
import { replaceCodePlugin } from 'vite-plugin-replace';
43

54
export default defineConfig({
65
build: {
76
outDir: 'build',
87
},
98
plugins: [
109
react(),
11-
replaceCodePlugin({
12-
replacements: [
13-
{
14-
from: '__RELEASE_INFO__',
15-
to: 'MTU5NjMxOTIwMDAwMA==', // 2020-08-02
16-
},
17-
{
18-
from: 'DISABLE_CHANCE_RANDOM',
19-
to: JSON.stringify(true),
20-
},
21-
],
22-
}),
10+
{
11+
name: 'replace-code',
12+
enforce: 'post',
13+
async transform(code) {
14+
return code
15+
.replaceAll('__RELEASE_INFO__', 'MTU5NjMxOTIwMDAwMA==') // 2020-08-02
16+
.replaceAll('DISABLE_CHANCE_RANDOM', 'true')
17+
},
18+
},
2319
],
2420
});

test/regressions/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
"react-router": "^7.3.0",
4242
"react-transition-group": "^4.4.5",
4343
"tsx": "^4.19.3",
44-
"vite": "^6.2.2",
45-
"vite-plugin-replace": "^0.1.1"
44+
"vite": "^6.2.2"
4645
}
4746
}

test/regressions/vite.config.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import url from 'url';
22
import path from 'path';
33
import { defineConfig, transformWithEsbuild } from 'vite';
44
import react from '@vitejs/plugin-react';
5-
import { replaceCodePlugin } from 'vite-plugin-replace';
65

76
const currentDirectory = url.fileURLToPath(new URL('.', import.meta.url));
87

@@ -24,18 +23,15 @@ export default defineConfig({
2423
},
2524
plugins: [
2625
react(),
27-
replaceCodePlugin({
28-
replacements: [
29-
{
30-
from: '__RELEASE_INFO__',
31-
to: 'MTU5NjMxOTIwMDAwMA==', // 2020-08-02
32-
},
33-
{
34-
from: 'DISABLE_CHANCE_RANDOM',
35-
to: JSON.stringify(true),
36-
},
37-
],
38-
}),
26+
{
27+
name: 'replace-code',
28+
enforce: 'post',
29+
async transform(code) {
30+
return code
31+
.replaceAll('__RELEASE_INFO__', 'MTU5NjMxOTIwMDAwMA==') // 2020-08-02
32+
.replaceAll('DISABLE_CHANCE_RANDOM', 'true')
33+
},
34+
},
3935
{
4036
name: 'js-files-as-jsx',
4137
enforce: 'pre',

0 commit comments

Comments
 (0)