npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@labor-digital/asset-building-dev-server

v2.0.0

Published

An Extension for the LABOR.digital asset-builder, that provides a dev server environment for webpack. Including support for multi-compilers and express

Downloads

6

Readme

LABOR - Asset Building - Dev Server Extension

This package is an extension to our asset building bundle.

When it comes to developing Single page applications (SPAs), you will find out sooner or later that it is convenient to have a local dev server that supports stuff like "hot-module-replacement".

The problem with webpack's default dev-server was, it does not work correctly when multiple apps run in the same domain (frontend and backend, for example). It also only works with real "webpack.js" files and not with the dynamic version we use. To circumvent that, and to make the integration as smooth as possible, we created our own dev server using express and webpack's middleware capabilities.

Installation

  • Install our asset builder:
npm install --save-dev @labor-digital/asset-building
  • Install the npm dependency:
npm install --save-dev @labor-digital/asset-building-dev-server
  • Add the provider plugin to your package.json
{ 
    "builderVersion": 2,
    [...]
    "extensions": [
        "@labor-digital/asset-building-dev-server"
    ]
}
  • Add the following part to your package.json:
  "scripts": {
    [...]
    "dev": "labor-asset-building dev"
  }
  • Start your server by running "npm run dev" -> The urls are printed to the console
  • Done! :-)

Adding the dev server to express apps

Our asset builder can run as a middleware in express, providing hot module replacement and webpack's dev features in the same way the "dev" command does for virtually every express app.

We provide a function you can use in your server.js file. It will only apply the required middlewares if your NODE_ENV variable is set to "development".

Register the express plugin in your index.js like:

const expressAssetBuildingPlugin = require("@labor-digital/asset-building/dist/Interop/Express/expressAssetBuildingPlugin.js");
const expressDevServerPlugin = require("@labor-digital/asset-building-dev-server/dist/ExpressDevServerPlugin");
const express = require("express");
const app = express();

// Apply the dev server plugin to the app
expressAssetBuildingPlugin(app)
   .then(expressDevServerPlugin)
    .then(() => {
        // Your express - app setup goes here...
    });

Changing the visible URL in the console

By default, the console will show a URL like http://js.localmachine.space:9999 when you are launching a new instance of a project. If you want to change the URL, you can do so by adding the "devUrl" option to your labor configuration in your package.json. The {{port}} placeholder will automatically be replaced with the correct port of your application.

{
    [...]
    "labor": {
        "devUrl": "http://yourUrl:{{port}}"
    }
}

Whats xyz.localmachine.space?

To work locally, you can work with an IP like 127.0.0.1, localhost, or you can point a DNS record to your local machine. The localmachine.space domain is precisely that. It is a domain name that always leads to "127.0.0.1", no matter what subdomain you use. Its a helper to make dev URLs more comfortable to read; it works on every machine as long as you have an internet connection.

Postcardware

You're free to use this package, but if it makes it to your production environment, we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: LABOR.digital - Fischtorplatz 21 - 55116 Mainz, Germany.

We publish all received postcards on our company website.