1.0.3 • Published 4 years ago

rollup-plugin-sitemap v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

rollup-plugin-sitemap

A Rollup plugin which takes a list of routes and generates a sitemap.xml file in a specified directory, normally your public folder.

Requirements

This plugin requires an LTS Node version (v8.0.0+) and Rollup v1.20.0+.

Install

Using npm:

npm install --save-dev rollup-plugin-sitemap

Using yarn:

yarn add --dev rollup-plugin-sitemap

Usage

Create a rollup.config.js configuration file and import the plugin:

import SitemapPlugin from 'rollup-plugin-sitemap';

const routes = [
  { path: '/', name: 'Home' },
  { path: '/test', name: 'Test' },
];

export default {
  input: 'src/index.js',
  output: {
    dir: 'output',
    format: 'cjs'
  },
  plugins: [
    SitemapPlugin({
      baseUrl: 'https://example.com',
      contentBase: 'public',
      routes,
    })
  ]
};

Then call rollup either via the CLI or the API.

Options

baseUrl

Type: String Default: null

A string to define what the base URL for the website of the sitemap.

contentBase

Type: String Default: 'public'

This will be the directory in your project where the sitemap.xml file will be generated. Normally this is named either public or dist.

routes

Type: Array[...Object] Default: null

A list of routes with two required properties, path and name. Name is there in case you want to define a route but not make it show up on the sitemap file. See the code above for an example of this value.

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago