🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@slorber/static-site-generator-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@slorber/static-site-generator-webpack-plugin

Minimal, unopinionated static site generator powered by webpack

4.0.7
latest
Source
npm
Version published
Maintainers
1
Created

What is @slorber/static-site-generator-webpack-plugin?

@slorber/static-site-generator-webpack-plugin is a Webpack plugin designed to generate static HTML files from your Webpack bundles. It is particularly useful for static site generation, allowing you to pre-render your React components or other JavaScript-based views into static HTML files.

What are @slorber/static-site-generator-webpack-plugin's main functionalities?

Basic Static Site Generation

This code demonstrates the basic setup for generating a static site using @slorber/static-site-generator-webpack-plugin. It specifies the entry point, output configuration, and initializes the plugin with paths to be pre-rendered.

const StaticSiteGeneratorPlugin = require('@slorber/static-site-generator-webpack-plugin');
const path = require('path');

module.exports = {
  entry: './src/index.js',
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist'),
    libraryTarget: 'umd'
  },
  plugins: [
    new StaticSiteGeneratorPlugin({
      entry: 'main',
      paths: ['/'],
      locals: {
        title: 'My Static Site'
      }
    })
  ]
};

Multiple Paths Generation

This example extends the basic setup to generate static HTML for multiple paths ('/', '/about', '/contact'). This is useful for sites with multiple pages.

const StaticSiteGeneratorPlugin = require('@slorber/static-site-generator-webpack-plugin');
const path = require('path');

module.exports = {
  entry: './src/index.js',
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist'),
    libraryTarget: 'umd'
  },
  plugins: [
    new StaticSiteGeneratorPlugin({
      entry: 'main',
      paths: ['/', '/about', '/contact'],
      locals: {
        title: 'My Static Site'
      }
    })
  ]
};

Using Locals for Dynamic Content

This example shows how to pass dynamic content to the static site generator using the 'locals' object. This can be used to inject data like titles, descriptions, or other metadata into the generated HTML.

const StaticSiteGeneratorPlugin = require('@slorber/static-site-generator-webpack-plugin');
const path = require('path');

module.exports = {
  entry: './src/index.js',
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist'),
    libraryTarget: 'umd'
  },
  plugins: [
    new StaticSiteGeneratorPlugin({
      entry: 'main',
      paths: ['/'],
      locals: {
        title: 'My Static Site',
        description: 'This is a description for my static site.'
      }
    })
  ]
};

Other packages similar to @slorber/static-site-generator-webpack-plugin

FAQs

Package last updated on 02 Jun 2022

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