-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
159 additions
and
404 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
'use strict'; | ||
|
||
const testBin = require('../helpers/test-bin'); | ||
const isWebpack5 = require('../helpers/isWebpack5'); | ||
|
||
describe('DevServer', () => { | ||
const webpack5Test = isWebpack5 ? it : it.skip; | ||
|
||
it('should add devServer entry points to a single entry point', (done) => { | ||
testBin('--config ./test/fixtures/dev-server/default-config.js') | ||
.then((output) => { | ||
expect(output.exitCode).toEqual(0); | ||
expect(output.stderr).toContain('client/default/index.js?'); | ||
done(); | ||
}) | ||
.catch(done); | ||
}); | ||
|
||
it('should add devServer entry points to a multi entry point object', (done) => { | ||
testBin('--config ./test/fixtures/dev-server/multi-entry.js') | ||
.then((output) => { | ||
expect(output.exitCode).toEqual(0); | ||
expect(output.stderr).toContain('client/default/index.js?'); | ||
expect(output.stderr).toContain('foo.js'); | ||
expect(output.stderr).toContain('bar.js'); | ||
done(); | ||
}) | ||
.catch(done); | ||
}); | ||
|
||
webpack5Test('should supports entry as descriptor', (done) => { | ||
testBin('--config ./test/fixtures/entry-as-descriptor/webpack.config --stats detailed') | ||
.then((output) => { | ||
expect(output.exitCode).toEqual(0); | ||
expect(output.stderr).toContain('foo.js'); | ||
done(); | ||
}) | ||
.catch(done); | ||
}); | ||
|
||
it('should only prepends devServer entry points to "web" target', (done) => { | ||
testBin('--config ./test/fixtures/dev-server/default-config.js --target web') | ||
.then((output) => { | ||
expect(output.exitCode).toEqual(0); | ||
expect(output.stderr).toContain('client/default/index.js?'); | ||
expect(output.stderr).toContain('foo.js'); | ||
done(); | ||
}) | ||
.catch(done); | ||
}); | ||
|
||
it('should not prepend devServer entry points to "node" target', (done) => { | ||
testBin('--config ./test/fixtures/dev-server/default-config.js --target node') | ||
.then((output) => { | ||
expect(output.exitCode).toEqual(0); | ||
expect(output.stderr).not.toContain('client/default/index.js?'); | ||
expect(output.stderr).toContain('foo.js'); | ||
done(); | ||
}) | ||
.catch(done); | ||
}); | ||
|
||
it('should prepends the hot runtime to "node" target as well', (done) => { | ||
testBin('--config ./test/fixtures/dev-server/default-config.js --target node --hot') | ||
.then((output) => { | ||
expect(output.exitCode).toEqual(0); | ||
expect(output.stderr).toContain('webpack/hot/dev-server'); | ||
done(); | ||
}) | ||
.catch(done); | ||
}); | ||
|
||
it('does not use client.path when default', (done) => { | ||
testBin('--config ./test/fixtures/dev-server/client-default-path-config.js') | ||
.then((output) => { | ||
expect(output.exitCode).toEqual(0); | ||
expect(output.stderr).not.toContain('&path=/ws'); | ||
done(); | ||
}) | ||
.catch(done); | ||
}); | ||
|
||
it('should use client.path when custom', (done) => { | ||
testBin('--config ./test/fixtures/dev-server/client-custom-path-config.js') | ||
.then((output) => { | ||
expect(output.exitCode).toEqual(0); | ||
expect(output.stderr).toContain('&path=/custom/path'); | ||
done(); | ||
}) | ||
.catch(done); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('I am bar'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const { resolve } = require('path'); | ||
|
||
module.exports = { | ||
mode: 'development', | ||
stats: 'detailed', | ||
entry: resolve(__dirname, './foo.js'), | ||
devServer: { | ||
client: { | ||
path: '/custom/path', | ||
}, | ||
transportMode: { | ||
server: 'sockjs', | ||
client: 'sockjs', | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const { resolve } = require('path'); | ||
|
||
module.exports = { | ||
mode: 'development', | ||
stats: 'detailed', | ||
entry: resolve(__dirname, './foo.js'), | ||
devServer: { | ||
client: { | ||
path: '/ws', | ||
}, | ||
transportMode: { | ||
server: 'sockjs', | ||
client: 'sockjs', | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const { resolve } = require('path'); | ||
|
||
module.exports = { | ||
mode: 'development', | ||
stats: 'detailed', | ||
entry: resolve(__dirname, './foo.js'), | ||
devServer: { | ||
client: { | ||
path: '/custom/path', | ||
}, | ||
transportMode: { | ||
server: 'sockjs', | ||
client: 'sockjs', | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('I am foo'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const { resolve } = require('path'); | ||
|
||
module.exports = { | ||
mode: 'development', | ||
stats: 'detailed', | ||
context: __dirname, | ||
entry: { | ||
foo: resolve(__dirname, './foo.js'), | ||
bar: resolve(__dirname, './bar.js'), | ||
}, | ||
devServer: { | ||
transportMode: { | ||
server: 'sockjs', | ||
client: 'sockjs', | ||
}, | ||
} | ||
} |
Oops, something went wrong.