Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@web/dev-server-core

Package Overview
Dependencies
Maintainers
7
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@web/dev-server-core

Web dev server core

  • 0.7.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
7
Weekly downloads
 
Created

What is @web/dev-server-core?

@web/dev-server-core is a core library for creating a modern web development server. It provides a flexible and extensible platform for serving web applications, with support for modern web features like ES modules, hot module replacement (HMR), and middleware.

What are @web/dev-server-core's main functionalities?

Basic Server Setup

This code demonstrates how to set up a basic development server using @web/dev-server-core. The server will serve files from the './public' directory on port 8080.

const { startDevServer } = require('@web/dev-server-core');

const config = {
  port: 8080,
  rootDir: './public',
};

startDevServer({ config }).then(server => {
  console.log(`Server running at http://localhost:${config.port}`);
});

Middleware Support

This example shows how to add middleware to the development server. The middleware logs each request URL to the console.

const { startDevServer } = require('@web/dev-server-core');

const config = {
  port: 8080,
  rootDir: './public',
  middleware: [
    (ctx, next) => {
      console.log(`Request: ${ctx.url}`);
      return next();
    }
  ]
};

startDevServer({ config }).then(server => {
  console.log(`Server running at http://localhost:${config.port}`);
});

Hot Module Replacement (HMR)

This code demonstrates how to enable Hot Module Replacement (HMR) in the development server. HMR allows modules to be updated in the browser without a full page reload.

const { startDevServer } = require('@web/dev-server-core');

const config = {
  port: 8080,
  rootDir: './public',
  watch: true,
  hmr: true
};

startDevServer({ config }).then(server => {
  console.log(`Server running with HMR at http://localhost:${config.port}`);
});

Other packages similar to @web/dev-server-core

Keywords

FAQs

Package last updated on 06 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc