Skip to content

Commit

Permalink
fix: run replacement of process.env.NODE_ENV for client-side (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
wkillerud authored Oct 30, 2023
1 parent 5bed296 commit 8100fba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions api/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
import { isAbsolute, join } from 'node:path';
import esbuild from 'esbuild';
import rollupPluginTerser from '@rollup/plugin-terser';
import rollupPluginReplace from '@rollup/plugin-replace';
import { rollup } from 'rollup';
import rollupPluginResolve from '@rollup/plugin-node-resolve';
import rollupPluginCommonjs from '@rollup/plugin-commonjs';
Expand Down Expand Up @@ -220,6 +221,15 @@ export async function build({ state, config, cwd = process.cwd() }) {
rollupPluginTerser({ format: { comments: false } }),
];

if (outfile) {
rollupPlugins.push(
rollupPluginReplace({
'process.env.NODE_ENV': JSON.stringify('production'),
preventAssignment: true,
}),
);
}

if (existsSync(join(cwd, 'tsconfig.json'))) {
rollupPlugins.unshift(
typescriptPlugin({ tsconfig: join(cwd, 'tsconfig.json') }),
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"@podium/podlet": "5.0.0-next.6",
"@rollup/plugin-commonjs": "25.0.2",
"@rollup/plugin-node-resolve": "15.1.0",
"@rollup/plugin-replace": "5.0.4",
"@rollup/plugin-terser": "0.4.3",
"@rollup/plugin-typescript": "11.1.2",
"@webcomponents/template-shadowroot": "0.2.1",
Expand Down

0 comments on commit 8100fba

Please sign in to comment.