diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d9eceb5..ef983832 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ * `terser-webpack-plugin` from 1 to 5 * `webpack-cli` from 3 to 4 * `webpack-manifest-plugin` from 2 to 3 - * `webpack-manifest-plugin` from 3 to 4-beta + * `webpack-dev-server` from 3 to 4-beta [CHANGELOG](https://github.com/webpack/webpack-dev-server/blob/master/CHANGELOG.md#400-beta0-2020-11-27) * [DEPENDENCY SUPPORT CHANGES] Encore has changed what versions it supports of the following packages: diff --git a/bin/encore.js b/bin/encore.js index 20e70444..c7e20140 100755 --- a/bin/encore.js +++ b/bin/encore.js @@ -77,7 +77,6 @@ function showUsageInstructions() { console.log(` ${chalk.green('dev-server')} : runs webpack-dev-server`); console.log(` - ${chalk.yellow('--host')} The hostname/ip address the webpack-dev-server will bind to`); console.log(` - ${chalk.yellow('--port')} The port the webpack-dev-server will bind to`); - console.log(` - ${chalk.yellow('--hot')} Enable HMR on webpack-dev-server`); console.log(` - ${chalk.yellow('--keep-public-path')} Do not change the public path (it is usually prefixed by the dev server URL)`); console.log(' - Supports any webpack-dev-server options'); console.log(); diff --git a/lib/WebpackConfig.js b/lib/WebpackConfig.js index 68fb8194..34e732ae 100644 --- a/lib/WebpackConfig.js +++ b/lib/WebpackConfig.js @@ -995,10 +995,6 @@ class WebpackConfig { return this.runtimeConfig.devServerHttps; } - useHotModuleReplacementPlugin() { - return this.runtimeConfig.useHotModuleReplacement; - } - isProduction() { return this.runtimeConfig.environment === 'production'; } diff --git a/lib/config-generator.js b/lib/config-generator.js index de80a0e0..19af6537 100644 --- a/lib/config-generator.js +++ b/lib/config-generator.js @@ -570,17 +570,15 @@ class ConfigGenerator { const contentBase = pathUtil.getContentBase(this.webpackConfig); const devServerOptions = { - contentBase: contentBase, - // this doesn't appear to be necessary, but here in case - publicPath: this.webpackConfig.getRealPublicPath(), + static: { + directory: contentBase, + // this doesn't appear to be necessary, but here in case + publicPath: this.webpackConfig.getRealPublicPath(), + }, // avoid CORS concerns trying to load things like fonts from the dev server headers: { 'Access-Control-Allow-Origin': '*' }, - hot: this.webpackConfig.useHotModuleReplacementPlugin(), - // required by FriendlyErrorsWebpackPlugin - quiet: true, compress: true, historyApiFallback: true, - watchOptions: this.buildWatchOptionsConfig(), https: this.webpackConfig.useDevServerInHttps() }; diff --git a/lib/config/RuntimeConfig.js b/lib/config/RuntimeConfig.js index 945a5208..084915be 100644 --- a/lib/config/RuntimeConfig.js +++ b/lib/config/RuntimeConfig.js @@ -20,7 +20,6 @@ class RuntimeConfig { this.devServerUrl = null; this.devServerHttps = null; this.devServerKeepPublicPath = false; - this.useHotModuleReplacement = false; this.outputJson = false; this.profile = false; diff --git a/lib/config/parse-runtime.js b/lib/config/parse-runtime.js index ae3b6db3..288ec10e 100644 --- a/lib/config/parse-runtime.js +++ b/lib/config/parse-runtime.js @@ -42,7 +42,6 @@ module.exports = function(argv, cwd) { runtimeConfig.useDevServer = true; runtimeConfig.devServerHttps = argv.https; - runtimeConfig.useHotModuleReplacement = argv.hot || false; runtimeConfig.devServerKeepPublicPath = argv.keepPublicPath || false; if (typeof argv.public === 'string') { diff --git a/test/config-generator.js b/test/config-generator.js index fb56a772..be110fe6 100644 --- a/test/config-generator.js +++ b/test/config-generator.js @@ -613,33 +613,6 @@ describe('The config-generator function', () => { expect(actualConfig.devServer).to.be.undefined; }); - it('devServer no hot mode', () => { - const config = createConfig(); - config.runtimeConfig.useDevServer = true; - config.runtimeConfig.devServerUrl = 'http://localhost:8080/'; - config.runtimeConfig.useHotModuleReplacement = false; - config.outputPath = isWindows ? 'C:\\tmp\\public' : '/tmp/public'; - config.setPublicPath('/'); - config.addEntry('main', './main'); - - const actualConfig = configGenerator(config); - expect(actualConfig.devServer).to.not.be.undefined; - expect(actualConfig.devServer.hot).to.be.false; - }); - - it('hot mode', () => { - const config = createConfig(); - config.runtimeConfig.useDevServer = true; - config.runtimeConfig.devServerUrl = 'http://localhost:8080/'; - config.runtimeConfig.useHotModuleReplacement = true; - config.outputPath = isWindows ? 'C:\\tmp\\public' : '/tmp/public'; - config.setPublicPath('/'); - config.addEntry('main', './main'); - - const actualConfig = configGenerator(config); - expect(actualConfig.devServer.hot).to.be.true; - }); - it('devServer with custom options', () => { const config = createConfig(); config.runtimeConfig.useDevServer = true; @@ -664,59 +637,6 @@ describe('The config-generator function', () => { }, }); }); - - it('devServer with custom watch options', () => { - const config = createConfig(); - config.runtimeConfig.useDevServer = true; - config.runtimeConfig.devServerUrl = 'http://localhost:8080/'; - config.runtimeConfig.useHotModuleReplacement = true; - config.outputPath = isWindows ? 'C:\\tmp\\public' : '/tmp/public'; - config.setPublicPath('/'); - config.addEntry('main', './main'); - - config.configureWatchOptions(watchOptions => { - watchOptions.poll = 250; - }); - - const actualConfig = configGenerator(config); - - expect(actualConfig.watchOptions).to.deep.equals({ - 'ignored': /node_modules/, - 'poll': 250, - }); - expect(actualConfig.devServer.watchOptions).to.deep.equals({ - 'ignored': /node_modules/, - 'poll': 250, - }); - }); - - it('devServer with custom options and watch options', () => { - const config = createConfig(); - config.runtimeConfig.useDevServer = true; - config.runtimeConfig.devServerUrl = 'http://localhost:8080/'; - config.runtimeConfig.useHotModuleReplacement = true; - config.outputPath = isWindows ? 'C:\\tmp\\public' : '/tmp/public'; - config.setPublicPath('/'); - config.addEntry('main', './main'); - - config.configureWatchOptions(watchOptions => { - watchOptions.poll = 250; - }); - config.configureDevServerOptions(options => { - // should take precedence over `configureWatchOptions()` - options.watchOptions.poll = 500; - }); - - const actualConfig = configGenerator(config); - expect(actualConfig.watchOptions).to.deep.equals({ - 'ignored': /node_modules/, - 'poll': 250, - }); - expect(actualConfig.devServer.watchOptions).to.deep.equals({ - 'ignored': /node_modules/, - 'poll': 500, - }); - }); }); describe('test for addPlugin config', () => { diff --git a/test/config/parse-runtime.js b/test/config/parse-runtime.js index 90575e31..3260d796 100644 --- a/test/config/parse-runtime.js +++ b/test/config/parse-runtime.js @@ -68,7 +68,6 @@ describe('parse-runtime', () => { expect(config.environment).to.equal('dev'); expect(config.useDevServer).to.be.true; expect(config.devServerUrl).to.equal('http://localhost:8080/'); - expect(config.useHotModuleReplacement).to.be.false; expect(config.devServerKeepPublicPath).to.be.false; }); @@ -132,14 +131,6 @@ describe('parse-runtime', () => { expect(config.babelRcFileExists).to.be.true; }); - it('dev-server command hot', () => { - const testDir = createTestDirectory(); - const config = parseArgv(createArgv(['dev-server', '--hot']), testDir); - - expect(config.useDevServer).to.be.true; - expect(config.useHotModuleReplacement).to.be.true; - }); - it('dev-server command --keep-public-path', () => { const testDir = createTestDirectory(); const config = parseArgv(createArgv(['dev-server', '--keep-public-path']), testDir);