Skip to content

Commit a02c083

Browse files
committed
Initial webpack v4 compatibility
1 parent 83c1625 commit a02c083

File tree

11 files changed

+4316
-2968
lines changed

11 files changed

+4316
-2968
lines changed

bin/webpack-dev-server.js

Lines changed: 6 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,9 @@ if (importLocal(__filename)) {
2424
const Server = require('../lib/Server');
2525
const webpack = require('webpack'); // eslint-disable-line
2626

27+
// webpack has a nice message when webpack-cli is not installed, by requiring it we can also show that
28+
require('webpack/bin/webpack');
29+
2730
function versionInfo() {
2831
return `webpack-dev-server ${require('../package.json').version}\n` +
2932
`webpack ${require('webpack/package.json').version}`;
@@ -51,7 +54,7 @@ const defaultTo = (value, def) => value == null ? def : value;
5154
const yargs = require('yargs')
5255
.usage(`${versionInfo()}\nUsage: https://webpack.js.org/configuration/dev-server/`);
5356

54-
require('webpack/bin/config-yargs')(yargs);
57+
require('webpack-cli/bin/config-yargs')(yargs);
5558

5659
// It is important that this is done after the webpack yargs config,
5760
// so it overrides webpack's version info.
@@ -220,7 +223,7 @@ yargs.options({
220223
});
221224

222225
const argv = yargs.argv;
223-
const wpOpt = require('webpack/bin/convert-argv')(yargs, argv, {
226+
const wpOpt = require('webpack-cli/bin/convert-argv')(yargs, argv, {
224227
outputFilename: '/bundle.js'
225228
});
226229

client-src/default/webpack.config.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
44

55
module.exports = {
6+
mode: 'development',
67
module: {
78
rules: [
89
{
@@ -16,7 +17,5 @@ module.exports = {
1617
}
1718
]
1819
},
19-
plugins: [
20-
new UglifyJSPlugin()
21-
]
20+
plugins: [new UglifyJSPlugin()]
2221
};

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 & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
55
const CopyPlugin = require('copy-webpack-plugin');
66

77
module.exports = {
8+
mode: 'development',
89
module: {
910
rules: [
1011
{
@@ -17,10 +18,8 @@ module.exports = {
1718
]
1819
},
1920
{
20-
test: /\.pug$/,
21-
use: [
22-
'pug-loader?self'
23-
]
21+
test: /\.html$/,
22+
use: ['html-loader'],
2423
},
2524
{
2625
test: /\.css$/,

client-src/sockjs/webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
55

66
module.exports = {
7+
mode: 'development',
78
output: {
89
library: 'SockJS',
910
libraryTarget: 'umd'

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)