Skip to content
This repository was archived by the owner on Jun 24, 2024. It is now read-only.

Commit 44754ef

Browse files
committed
feat: replace NODE_ENV 2 enable DCE when minifying
1 parent 58958a5 commit 44754ef

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

lib/reader.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const feedSchema = require('./feed-schema');
1212
const uglify = require('uglify-es');
1313
const Boom = require('boom');
1414
const assert = require('assert');
15+
const envify = require('envify');
1516

1617
/**
1718
* Unpacks given feeds into directory structure before
@@ -42,7 +43,12 @@ module.exports = async (feeds, options) => {
4243
});
4344
});
4445

45-
const opts = { sourceMaps: false, minify: false, ...options };
46+
const opts = {
47+
sourceMaps: false,
48+
minify: false,
49+
env: process.env.NODE_ENV || 'development',
50+
...options,
51+
};
4652

4753
if (!opts.directory) {
4854
opts.directory = directory();
@@ -63,6 +69,11 @@ module.exports = async (feeds, options) => {
6369

6470
const bundler = browserify({ entries, debug: opts.sourceMaps });
6571

72+
bundler.transform(envify, {
73+
_: 'purge',
74+
NODE_ENV: opts.env,
75+
});
76+
6677
let bundle = await getStream(bundler.bundle());
6778

6879
if (opts.minify) {

package-lock.json

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

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"asset-pipe-common": "^1.0.0-beta.6",
3030
"boom": "^7.1.1",
3131
"browserify": "^15.2.0",
32+
"envify": "^4.1.0",
3233
"fs-extra": "^5.0.0",
3334
"joi": "^13.1.1",
3435
"readable-stream": "^2.3.3",

0 commit comments

Comments
 (0)