Giter Club home page Giter Club logo

midori-webpack's Introduction

midori-webpack

Combine midori and webpack ❤️.

build status coverage license version downloads

If you're serving webpack assets or need to attach information about your webpack assets to your midori request handler then you can use midori-webpack to do just that. Usage is simple and also supports development mode using both webpack-dev-server and webpack-udev-server.

Usage

npm install --save midori-webpack

Simple example:

import {compose, request, send, get} from 'midori';
import {withStats, serveStatic} from 'midori-webpack';

const isDev = process.env.NODE_ENV === 'development' || !process.env.NODE_ENV;

const createApp = compose(
  // Attach `stats` to the `request` object. This can be a URL if you're using
  // `webpack-dev-server` since nothing is generated on the local filesystem.
  // If you're using `webpack-udev-server` then everything is handled for you
  // internally and you can just use the normal filename.
  withStats(
    isDev ? 'http://localhost:8080/js/stats.json' : './dist/stats.json'
  ),

  // Serve all your webpack assets with the correct `publicPath`. This assumes
  // all your generated assets live in the same folder as your `stats.json`.
  serve('./dist/stats.json'),

  // Dump the stats for fun.
  get('/stats', request((req) => {
    return send(JSON.stringify(req.stats));
  })),
);

const app = createApp();
app.listen(8888);

You can find a complete example including instructions on how to run it in various modes in the [demo] folder.

midori-webpack's People

Contributors

izaakschroeder avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.