Giter Club home page Giter Club logo

webpack-intermediate-entry's Introduction

Webpack Intermediate Entry



A webpack plugin allowing you to specify a "middleware" file which takes the place of your entries. With it you can programatically bundle any number of entry modules, all of which should share a common bootstraping logic. For each entry file, the common module will be loaded instead. Within that common module, importing __webpack_entry__ will resolve to the original entry file respective to each instance of the common, inserted module.



Use Case

Similarly to a React Next.js stack, you might have a folder containing a number of modules. Each of those export a default component, which supplies the "page" for a named route. This plugin allows a similar workflow, but to those who prefer shipping static page-bundles using HTMLWebpackPlugin, thus bypassing SSR.



Install

npm install --save-dev webpack-intermediate-entry


How to use

Check out /example in this repo for a good example of how this plugin fits into a project.


In your config, import and include this package amongst your plugins.

  • webpack.config.js
const IntermediateEntryPlugin = require("webpack-intermediate-entry");

module.exports = {
    entry: {
        hello: "./hello.js"
    },
    plugins: [
        new IntermediateEntryPlugin({ insert: "./init.js" })
    ]
}

In your config, import and include this package amongst your plugins.

  • hello.js
export default "Hello World!"

Within your intermediate, you can include common init logic. Simply import your actual entry and do what you will with it.

  • init.js
import Entry from "__webpack_entry__";

console.log(Entry);

In a more realistic use case, init.js might contain a ReactDOM.render() call, which consumes the component suppliedby your entries.


License

MIT License

webpack-intermediate-entry's People

Contributors

carlbennettnz avatar gabeklein avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

carlbennettnz

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.