Snowpack Rollup Bundling Plugin

0.4.4 · maintenance · verified Tue Apr 21

snowpack-plugin-rollup-bundle is a Snowpack plugin designed to integrate Rollup for production bundling of web applications. The package, currently at version 0.4.4, provides functionality to process specified entrypoints (relative to the Snowpack `build/` directory), bundling them along with their corresponding CSS files and generating a `manifest.json` for hashed asset locations. It was initially developed with a focus on seamless integration with Rails applications, particularly through the `Snowpacker` gem. While it fulfills its purpose for Snowpack projects, it's important to note that Snowpack itself has largely been unmaintained since 2021, with its creators now recommending alternatives like Vite for new development. Consequently, this plugin is primarily relevant for maintaining or optimizing existing Snowpack-based projects rather than serving new build tooling initiatives.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart shows a typical `snowpack.config.js` setup for `snowpack-plugin-rollup-bundle`, demonstrating how to enable HTML file rewriting, specify entrypoints, and extend the underlying Rollup configuration with custom plugins or options.

// snowpack.config.js
const awesomeRollupPlugin = require('awesome-rollup-plugin'); // Example for extending config

module.exports = {
  mount: {
    'src': '/',
  },
  plugins: [
    // Other Snowpack plugins...
    [
      "snowpack-plugin-rollup-bundle",
      {
        emitHtmlFiles: true, // Set to true to rewrite script tags in HTML
        preserveSourceFiles: false,
        entrypoints: [
          "build/_dist_/index.js",
          "build/_dist_/entrypoints/*.js",
        ], // Required: glob patterns or array of paths relative to build/
        extendConfig: (config) => {
          // Example: Add a custom Rollup plugin
          config.inputOptions.plugins.push(awesomeRollupPlugin());
          // Example: Override output options
          config.outputOptions = {
            ...config.outputOptions,
            chunkFileNames: 'chunks/[name]-[hash].js',
            assetFileNames: 'assets/[name]-[hash][extname]'
          };
          return config;
        }
      }
    ]
  ],
  build: {
    out: 'dist',
    metaDir: '_snowpack_',
  },
  optimize: {
    bundle: false, // Ensure Snowpack's built-in bundler is off if using this plugin
  },
};

view raw JSON →