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

flamingo-carotene-dev-server

v9.0.0-alpha.13

Published

Provide the functionality to add file watchers for developing projects with the Flamingo Carotene tooling

Downloads

30

Readme

Module flamingo-carotene-dev-server

The dev server module is there to make the development of a Flamingo Carotene frontend easier.

It includes the functionality to register chokidar file watchers and dispatch commands when these noticed a change.

In addition to that a socket.io socket will be opened and its client will be injected into the webpack config (if available) to automatically reload the browser after a potential successful rebuild.

The NODE_ENV is set to development when executing the dev servers command.

How to use

Get the module by running:

npm i -D flamingo-carotene-dev-server

The dev server will listen to the dev command.

By executing:

npx flamingo-carotene dev

the dev server will start gathering all configured watchers used inside your project and start separate file watchers.

Setup File Watchers

To set up file watchers you can easily add a watcher config to your module definition with the following structure

{
  'watchId': 'myId',
  'path': [
    path.join(config.paths.src, '**', '*.ext')
  ],
  'command': 'commandName',
  'callbackKey': 'configKey',
  'watcherConfig': {
    ignored: /(^|[/\\])\../ // dot files or folders
  },
  'unwatchConfig': path.join(config.paths.src, '**', 'special.ext')
}

watchId A unique id (at least in your project) to identify the file watcher.

path The glob paths that the file watcher should check for file changes.

command The command that will be dispatched when a file change was recognized.

callbackKey A key from the config where to find a buildCallback function. Only one level supported yet, e.g. when your callback function is located here: config.myKey.buildCallback the callbackKey would be myKey. This function is also used to allow the rebuild functionality when changes are made during a running build.

watcherConfig (optional) A custom config object for this chokidar file watcher.

unwatchConfig (optional) string or array of strings of file-, directory-, or glob-paths

The watcher configurations will be automatically gathered by the dev server by calling the getWatchers function, that must be provided by your module to expose your watcher configs.

How to configure

This module exposes the following config

config.devServer = {
  port: 3000,
  injectSocket: true,
  useCaroteneDisplay: true,
  watcherConfig: {
    ignored: /(^|[/\\])\../ // dot files or folders
  }
}

port The port of the dev server is used for the socket connection to the client. injectSocket Set this to false, if you dont want dev-server code to be injected into your app.js while watcher is running. Note: carotenedisplay and hot/autoreload cant be used. useCaroteneDisplay Set this to false, if you dont want to display build and/or debug information in your browser while watcher is running.

How socket client injection works

The socket client will be injected into the webpack config's entries. If you have more that one entry for js, each entry will get the ability to open its socket to the server on execution. When the dev command was dispatched and the last build was no dev build - no socket client was injected - the js watcher command will be triggered right away to ensure that the next page load will have the ability to communicate via the socket.