New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-static-page-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-static-page-webpack-plugin

A webpack that generates an html page from a react component

latest
Source
npmnpm
Version
1.2.1
Version published
Maintainers
1
Created
Source

ReactStaticPageWebpackPlugin

A webpack that generates an html page from a react component

Usage

yarn add react-static-page-webpack-plugin -D

webpack.config.js

exports = {
  entry './src/static-page.js',
  output: {
    libraryTarget: 'commonjs'
  }
  plugins: [
    new ReactStaticPageWebpackPlugin({
      fileName: 'static-index.html',
      title: 'My Page Title',
      props: {
        customerName: 'Sally'
      }
    }),
  ],
};

And in ./src/static-page.js:

import React from 'react';

export default function StaticPage({ customerName }) {
  return <main>Hi there: {customerName}</main>;
}

When running the webpack build static-index.html will be written to your output folder.

Options

  • chunk: Specific the entry chunk that returns the body component you want to render, optional, will use the first chunk when omitted
  • fileName: The output file name
  • title: A page title placed in teh <head>
  • meta: a string of meta tags placed into the document <head>
  • props: An set of props that is passed to your component.

Why use a webpack chunk?

The reason we use an entry chunk (instead of providing a filename to the component) is so you can leaverage your existing webpack config for styling, and compilation.

FAQs

Package last updated on 25 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts