Code Monkey home page Code Monkey logo

ezreal's Introduction

Logo

Chain building your complex webpackConfig.

NPM Version Package License NPM Downloads

Introduction

Ezreal combines some middleware with a preset to build your webpackConfig. Why not use neutrinoJs ?For more details, you can read this pr.

So ezreal can do even better in the following areas

  1. Single responsibility principle: a middleware does only one thing
  2. Preset support: the preset concept makes it easy to publish to npm to share your configuration
  3. Pipeline build: instead of nested call, flat call middleware one by one
  4. No side effects: the code implementation makes it more side-effect-free and pure

Read more

Getting started

yarn add ezreal-core
const bootstrap = require("ezreal-core");

const webpackConfig = bootstrap({
  // my-preset-react is an npm package or a file
  extends: require.resolve('my-preset-react'),
  middleware: [
    require.resolve('my-middleware-prerender'),
    require.resolve('my-middleware-microFrontEnd'),
    require.resolve('my-middleware-packageCheck'),
    require.resolve('my-middleware-esCheck'),
    require.resolve('my-middleware-sentry'),
    ...
  ]
}).webpack();

Examples

A simple web project

Can provide you with webpackConfig

// examples/simple/webpack.config.js
const bootstrap = require("ezreal-core");

// If there is no .ezrealrc.js
// Can be called directly from a pure function
// bootstrap({
//   extends: "ezreal-preset-react"
// }).webpack();

module.exports = bootstrap().webpack();

A command line tool

Provide different user configurations for command line tools

// my-cli.js
const bootstrap = require("ezreal-core");
const webpackConfig = bootstrap().webpack();

Better support for different types of projects

// project-a
// .ezrealrc.js
module.exports = {
   extends: "my-preset-mobile" // extends: my-preset-react
}

// project-b
// .ezrealrc.js
module.exports = {
   extends: "my-preset-pc" // extends: my-preset-react
}

Advanced

middleware

modules.exports = function MyAnalyzerMiddleware(chain, options) {
  if (options.analyze) {
    chain
      .plugin('webpack-bundle-analyzer')
      .use(new BundleAnalyzerPlugin(options.analyze));
  }
}

preset

modules.exports = {
  extends: require.resolve('ezreal-preset-react'),
  middleware: [require.resolve('./my-analyzer-middleware')],
  // Set a default value, with a lower priority than the user's configuration
  options: {
    analyze: true
  }
}

License

MIT licensed.

ezreal's People

Contributors

xiaoxiaojx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.