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

mrbuilder-plugin-html

v3.3.1

Published

html plugin for mrbuilder

Downloads

144

Readme

The HTML plugin allows for testing of components, and for compiling pages. It is a wrapper around HtmlWebpackPlugin.

By default looks first for a public/index.js to bootstrap your app, if it does not exist, than it uses a synthetic file that looks like

    import React from 'react';
    import {render} from 'react-dom';
    import App from 'your-module';
    render(<App/>, document.getElementById('content'))

More than likely you should write your own render component, that looks similar

Configuration

In package.json

 "name":"your_component",
 ...
 "mrbuilder":{
    "plugins":[
        "mrbuilder-plugin-html"
    ]
 }

Custom Element

To configure which element your component renders to use elementId property, where the value is the dom Id. By default it is "content".

Hot loading

Hot loading setup is always a PNA -- this attempts to make it easier, however to do this your "App" must export a class rather than the traditional export.

This can be controlled via the exported flag either per "page" or for all "pages".

Custom Hot Loading

If exported is false, than you will need to set hot loading in your page, and your running hot see step 4. The rest of the steps are already done for you.

An example can be found here;

It should look something like.


"mrbuilder":{
    "plugins":[
        ["mrbuilder-plugin-html", {exported:false}]
    ]
 }

Your entry point should look something like.

// main.js
import React from 'react'
import ReactDOM from 'react-dom'
import { AppContainer } from 'react-hot-loader'
import App from './containers/App'

const render = Component => {
  ReactDOM.render(
    <AppContainer>
      <Component />
    </AppContainer>,
    document.getElementById('root'),
  )
}

render(App)

// Webpack Hot Module Replacement API
if (module.hot) {
  module.hot.accept('./containers/App', () => {
    render(App)
  })
}


Pages

The pages points can be configured via pages object where the key will match the entry point, or by default it will look into public/index.js, failing that it will use the main defined in your package.json.

"mrbuilder":[
[
        "mrbuilder-plugin-html",
        {
          "pages": {
            "index": {//"index will match your entry for index.
              "title": "Index" // will set the title for the page.
            },
            "other": {
              "title": "Other",
              "exported": true // will tell the html plugin to create a real entry point and setup loading for this.
            }
          }
        }
      ]
]