Webpack Dev Server Wait Page

3.0.0 · active · verified Tue Apr 21

webpack-dev-server-waitpage provides a visual progress page for `webpack-dev-server`, displaying compilation status to users instead of a blank screen during development. It is currently at version 3.0.0, offering compatibility with modern Node.js environments and Webpack 5. The package aims to improve developer experience by offering immediate visual feedback on the build process. It differentiates itself through customizable themes (default, dark, material) and support for custom EJS templates, allowing developers to brand or tailor the waiting experience. The library functions as both a Webpack plugin and a `webpack-dev-server` middleware, supporting multiple Webpack configurations. Release cadence is driven primarily by updates to Webpack and `webpack-dev-server` itself, ensuring continued compatibility.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to integrate `webpack-dev-server-waitpage` into a TypeScript Webpack 5 project. It shows adding both the plugin to the `plugins` array and the middleware to the `devServer.onBeforeSetupMiddleware` hook, configured with a 'material' theme and custom title.

import path from 'path';
import { Configuration } from 'webpack';
import webpackDevServerWaitpage from 'webpack-dev-server-waitpage';

const config: Configuration = {
  mode: 'development',
  entry: './src/index.ts',
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist'),
    publicPath: '/',
  },
  module: {
    rules: [
      {
        test: /\.ts$/,
        use: 'ts-loader',
        exclude: /node_modules/,
      },
      {
        test: /\.css$/,
        use: ['style-loader', 'css-loader'],
      },
    ],
  },
  resolve: {
    extensions: ['.ts', '.js', '.json'],
  },
  plugins: [
    // Add the waitpage plugin to the webpack plugins array
    webpackDevServerWaitpage.plugin(),
  ],
  devServer: {
    port: 8080,
    open: true,
    hot: true,
    // For webpack-dev-server@4+, use onBeforeSetupMiddleware
    onBeforeSetupMiddleware: (server) => {
      // Pass the server instance to the waitpage middleware
      server.app.use(webpackDevServerWaitpage(server, { theme: 'material', title: 'Loading App...' }));
    },
    // For webpack-dev-server@3, use before
    // before: (app, server) => {
    //   app.use(webpackDevServerWaitpage(server, { theme: 'material', title: 'Loading App...' }));
    // },
  },
};

export default config;

view raw JSON →