Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.

Commit 8100fba

Browse files
authored
fix: run replacement of process.env.NODE_ENV for client-side (#126)
1 parent 5bed296 commit 8100fba

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

api/build.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
22
import { isAbsolute, join } from 'node:path';
33
import esbuild from 'esbuild';
44
import rollupPluginTerser from '@rollup/plugin-terser';
5+
import rollupPluginReplace from '@rollup/plugin-replace';
56
import { rollup } from 'rollup';
67
import rollupPluginResolve from '@rollup/plugin-node-resolve';
78
import rollupPluginCommonjs from '@rollup/plugin-commonjs';
@@ -220,6 +221,15 @@ export async function build({ state, config, cwd = process.cwd() }) {
220221
rollupPluginTerser({ format: { comments: false } }),
221222
];
222223

224+
if (outfile) {
225+
rollupPlugins.push(
226+
rollupPluginReplace({
227+
'process.env.NODE_ENV': JSON.stringify('production'),
228+
preventAssignment: true,
229+
}),
230+
);
231+
}
232+
223233
if (existsSync(join(cwd, 'tsconfig.json'))) {
224234
rollupPlugins.unshift(
225235
typescriptPlugin({ tsconfig: join(cwd, 'tsconfig.json') }),

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"@podium/podlet": "5.0.0-next.6",
4747
"@rollup/plugin-commonjs": "25.0.2",
4848
"@rollup/plugin-node-resolve": "15.1.0",
49+
"@rollup/plugin-replace": "5.0.4",
4950
"@rollup/plugin-terser": "0.4.3",
5051
"@rollup/plugin-typescript": "11.1.2",
5152
"@webcomponents/template-shadowroot": "0.2.1",

0 commit comments

Comments
 (0)