Skip to content

Commit 7378e3e

Browse files
committed
Merge branch 'webpack-4'
2 parents ab4eeb0 + dbea323 commit 7378e3e

File tree

18 files changed

+4885
-2806
lines changed

18 files changed

+4885
-2806
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ the [`before`](https://webpack.js.org/configuration/dev-server/#devserver-before
2828
and [`after`](https://webpack.js.org/configuration/dev-server/#devserver-after)
2929
hooks in the documentation.
3030

31+
Use [webpack-serve](https://github.com/webpack-contrib/webpack-serve) for a fast alternative. Use webpack-dev-server if you need to test on old browsers.
32+
3133
## Getting Started
3234

3335
First thing's first, install the module:

bin/webpack-dev-server.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
'use strict';
44

5-
/* eslint global-require: off, import/order: off, no-console: off */
5+
/* eslint global-require: off, import/order: off, no-console: off, import/no-extraneous-dependencies: off */
66
require('../lib/polyfills');
77

88
const debug = require('debug')('webpack-dev-server');
@@ -24,6 +24,16 @@ if (importLocal(__filename)) {
2424
const Server = require('../lib/Server');
2525
const webpack = require('webpack'); // eslint-disable-line
2626

27+
try {
28+
require.resolve('webpack-cli');
29+
} catch (e) {
30+
console.error('The CLI moved into a separate package: webpack-cli.');
31+
console.error("Please install 'webpack-cli' in addition to webpack itself to use the CLI.");
32+
console.error('-> When using npm: npm install webpack-cli -D');
33+
console.error('-> When using yarn: yarn add webpack-cli -D');
34+
process.exitCode = 1;
35+
}
36+
2737
function versionInfo() {
2838
return `webpack-dev-server ${require('../package.json').version}\n` +
2939
`webpack ${require('webpack/package.json').version}`;
@@ -51,7 +61,7 @@ const defaultTo = (value, def) => value == null ? def : value;
5161
const yargs = require('yargs')
5262
.usage(`${versionInfo()}\nUsage: https://webpack.js.org/configuration/dev-server/`);
5363

54-
require('webpack/bin/config-yargs')(yargs);
64+
require('webpack-cli/bin/config-yargs')(yargs);
5565

5666
// It is important that this is done after the webpack yargs config,
5767
// so it overrides webpack's version info.
@@ -220,7 +230,7 @@ yargs.options({
220230
});
221231

222232
const argv = yargs.argv;
223-
const wpOpt = require('webpack/bin/convert-argv')(yargs, argv, {
233+
const wpOpt = require('webpack-cli/bin/convert-argv')(yargs, argv, {
224234
outputFilename: '/bundle.js'
225235
});
226236

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
'use strict';
22

3-
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
4-
53
module.exports = {
4+
mode: 'production',
65
module: {
76
rules: [
87
{
@@ -15,8 +14,5 @@ module.exports = {
1514
]
1615
}
1716
]
18-
},
19-
plugins: [
20-
new UglifyJSPlugin()
21-
]
17+
}
2218
};

client-src/live/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ let hot = false;
1111
let currentHash = '';
1212

1313
$(() => {
14-
$('body').html(require('./page.pug')());
14+
$('body').html(require('./page.html')());
1515
const status = $('#status');
1616
const okness = $('#okness');
1717
const $errors = $('#errors');

client-src/live/page.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div class="header">
2+
<span id="okness"></span>
3+
<span id="status"></span>
4+
</div>
5+
<pre id="errors"></pre>
6+
<div id="warnings"></div>
7+
<iframe id="iframe" src="javascript:;" allowfullscreen="allowfullscreen"></iframe>

client-src/live/page.pug

Lines changed: 0 additions & 7 deletions
This file was deleted.

client-src/live/webpack.config.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
'use strict';
22

33
const path = require('path');
4-
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
54
const CopyPlugin = require('copy-webpack-plugin');
65

76
module.exports = {
7+
mode: 'production',
88
module: {
99
rules: [
1010
{
@@ -17,10 +17,8 @@ module.exports = {
1717
]
1818
},
1919
{
20-
test: /\.pug$/,
21-
use: [
22-
'pug-loader?self'
23-
]
20+
test: /\.html$/,
21+
use: ['html-loader']
2422
},
2523
{
2624
test: /\.css$/,
@@ -32,7 +30,6 @@ module.exports = {
3230
]
3331
},
3432
plugins: [
35-
new UglifyJSPlugin(),
3633
new CopyPlugin([{
3734
from: path.resolve(__dirname, 'live.html'),
3835
to: path.resolve(__dirname, '../../client/live.html')
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
'use strict';
22

3-
// eslint-disable-next-line
4-
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
5-
63
module.exports = {
4+
mode: 'production',
75
output: {
86
library: 'SockJS',
97
libraryTarget: 'umd'
10-
},
11-
plugins: [
12-
new UglifyJSPlugin()
13-
]
8+
}
149
};

examples/api/middleware/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const { setup } = require('../../util');
66

77
module.exports = setup({
88
context: __dirname,
9-
entry: ['./app.js', '../../client/index.js?http://localhost:8080/'],
9+
entry: ['./app.js', '../../../client/index.js?http://localhost:8080/'],
1010
output: {
1111
filename: 'bundle.js'
1212
}

examples/util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const webpack = require('webpack');
1010

1111
module.exports = {
1212
setup(config) {
13-
const defaults = { plugins: [], devServer: {} };
13+
const defaults = { mode: 'development', plugins: [], devServer: {} };
1414
const result = Object.assign(defaults, config);
1515
const before = function before(app) {
1616
app.get('/.assets/*', (req, res) => {

0 commit comments

Comments
 (0)