Skip to content

Commit 2fc3c51

Browse files
committed
fix: set process.env variables to remove non-production code
1 parent db5c0d3 commit 2fc3c51

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
run: npm install
4545

4646
# - name: Format ✨
47-
# run: npm run test.format
47+
# run: npm run test.format
4848

4949
- name: Lint ✨
5050
run: npm run test.lint

src/.terserrc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const isReadable = isDev || isTest
55
const ProductionCompress = {
66
global_defs: {
77
// remove dev and test specific code for production
8+
"process.env.NODE_ENV": process.env.NODE_ENV || "production",
9+
"process.env.BABEL_ENV": process.env.BABEL_ENV || process.env.NODE_ENV || "production",
810
"@atom.inSpecMode": !isTest ? "() => false" : "() => true",
911
"@atom.inDevMode": !isDev ? "() => false" : "() => true",
1012
},

test/index-spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ describe("Terser-Config-Atomic", () => {
1111

1212
expect(typeof TerserOptions).toBe("object")
1313
expect(TerserOptions.compress.global_defs).toEqual({
14+
"process.env.NODE_ENV": "production",
15+
"process.env.BABEL_ENV": "production",
1416
"@atom.inSpecMode": "() => false",
1517
"@atom.inDevMode": "() => false",
1618
})
@@ -35,6 +37,8 @@ describe("Terser-Config-Atomic", () => {
3537

3638
expect(typeof TerserOptions).toBe("object")
3739
expect(TerserOptions.compress.global_defs).toEqual({
40+
"process.env.NODE_ENV": "test",
41+
"process.env.BABEL_ENV": "test",
3842
"@atom.inSpecMode": "() => true",
3943
"@atom.inDevMode": "() => false",
4044
})

0 commit comments

Comments
 (0)