Skip to content

Commit

Permalink
feat(server): add WEBPACK_DEV_SERVER env variable (#1929)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored and hiroppy committed May 27, 2019
1 parent 4b097e2 commit 856169e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ if (semver.satisfies(process.version, '8.6.0 - 9')) {
tls.DEFAULT_ECDH_CURVE = 'auto';
}

if (!process.env.WEBPACK_DEV_SERVER) {
process.env.WEBPACK_DEV_SERVER = true;
}

class Server {
constructor(compiler, options = {}, _log) {
if (options.lazy && !options.filename) {
Expand Down
26 changes: 26 additions & 0 deletions test/Server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,4 +474,30 @@ describe('Server', () => {
afterAll(testServer.close);
});
});

describe('WEBPACK_DEV_SERVER environment variable', () => {
const OLD_ENV = process.env;

beforeEach(() => {
// this is important - it clears the cache
jest.resetModules();

process.env = { ...OLD_ENV };

delete process.env.WEBPACK_DEV_SERVER;
});

afterEach(() => {
process.env = OLD_ENV;
});

it('should be present', () => {
expect(process.env.WEBPACK_DEV_SERVER).toBeUndefined();

// eslint-disable-next-line global-require
require('../lib/Server');

expect(process.env.WEBPACK_DEV_SERVER).toBe(true);
});
});
});

0 comments on commit 856169e

Please sign in to comment.