Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bin/webpack-dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ yargs.options(options);

const argv = yargs.argv;

process.env.WEBPACK_DEV_SERVER = true;

// [email protected] path : 'webpack-cli/bin/utils/convert-argv'
let convertArgvPath;
try {
Expand Down
2 changes: 2 additions & 0 deletions lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ class Server {
throw new Error("'filename' option must be set in lazy mode.");
}

process.env.WEBPACK_DEV_SERVER = true;

// if the user enables http2, we can safely enable https
if (options.http2 && !options.https) {
options.https = true;
Expand Down
7 changes: 7 additions & 0 deletions test/Server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ const config = require('./fixtures/simple-config/webpack.config');
const helper = require('./helper');

describe('Server', () => {
it('process.env.WEBPACK_DEV_SERVER', () => {
const compiler = webpack(config);
// eslint-disable-next-line no-new
new Server(compiler);
expect(process.env.WEBPACK_DEV_SERVER).toBeTruthy();
});

describe('addEntries', () => {
it('add hot option', () => {
return new Promise((res) => {
Expand Down
9 changes: 9 additions & 0 deletions test/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ const keyPath = path.join(httpsCertificateDirectory, 'server.key');
const certPath = path.join(httpsCertificateDirectory, 'server.crt');

describe('CLI', () => {
it('process.env.WEBPACK_DEV_SERVER', (done) => {
runDevServer()
.then(() => {
expect(process.env.WEBPACK_DEV_SERVER).toBeTruthy();
done();
})
.catch(done);
});

it('--progress', (done) => {
runDevServer('--progress')
.then((output) => {
Expand Down