{"id":15834,"library":"snowpack-plugin-rollup-bundle","title":"Snowpack Rollup Bundling Plugin","description":"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.","status":"maintenance","version":"0.4.4","language":"javascript","source_language":"en","source_url":"https://github.com/ParamagicDev/snowpack-plugin-rollup-bundle","tags":["javascript"],"install":[{"cmd":"npm install snowpack-plugin-rollup-bundle","lang":"bash","label":"npm"},{"cmd":"yarn add snowpack-plugin-rollup-bundle","lang":"bash","label":"yarn"},{"cmd":"pnpm add snowpack-plugin-rollup-bundle","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Rollup is the core bundler that snowpack-plugin-rollup-bundle integrates to perform production bundling. It is a peer dependency.","package":"rollup","optional":false},{"reason":"Snowpack is the host build tool for which this plugin provides extended functionality. It is a peer dependency.","package":"snowpack","optional":false}],"imports":[{"note":"This plugin is configured by adding its name and options directly to the `plugins` array in your `snowpack.config.js`. Snowpack config files typically use CommonJS modules.","wrong":"import { snowpackPluginRollupBundle } from 'snowpack-plugin-rollup-bundle';","symbol":"snowpack-plugin-rollup-bundle","correct":"// snowpack.config.js\nmodule.exports = {\n  plugins: [\n    ['snowpack-plugin-rollup-bundle', { /* options */ }]\n  ]\n};"},{"note":"When using `extendConfig` to add custom Rollup plugins, you typically `require` them within your `snowpack.config.js` file, which is a CommonJS context.","symbol":"awesomeRollupPlugin","correct":"const awesomeRollupPlugin = require('awesome-rollup-plugin');"},{"note":"The entire `snowpack.config.js` file is usually a CommonJS module exporting the configuration object.","symbol":"SnowpackConfig","correct":"const plugins = [\n  // ...\n  [\"snowpack-plugin-rollup-bundle\", { /* options */ }]\n];\nmodule.exports = {\n  plugins: plugins\n};"}],"quickstart":{"code":"// snowpack.config.js\nconst awesomeRollupPlugin = require('awesome-rollup-plugin'); // Example for extending config\n\nmodule.exports = {\n  mount: {\n    'src': '/',\n  },\n  plugins: [\n    // Other Snowpack plugins...\n    [\n      \"snowpack-plugin-rollup-bundle\",\n      {\n        emitHtmlFiles: true, // Set to true to rewrite script tags in HTML\n        preserveSourceFiles: false,\n        entrypoints: [\n          \"build/_dist_/index.js\",\n          \"build/_dist_/entrypoints/*.js\",\n        ], // Required: glob patterns or array of paths relative to build/\n        extendConfig: (config) => {\n          // Example: Add a custom Rollup plugin\n          config.inputOptions.plugins.push(awesomeRollupPlugin());\n          // Example: Override output options\n          config.outputOptions = {\n            ...config.outputOptions,\n            chunkFileNames: 'chunks/[name]-[hash].js',\n            assetFileNames: 'assets/[name]-[hash][extname]'\n          };\n          return config;\n        }\n      }\n    ]\n  ],\n  build: {\n    out: 'dist',\n    metaDir: '_snowpack_',\n  },\n  optimize: {\n    bundle: false, // Ensure Snowpack's built-in bundler is off if using this plugin\n  },\n};\n","lang":"javascript","description":"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."},"warnings":[{"fix":"Update your Snowpack configuration to use `emitHtmlFiles: true` instead of `emitHtml: true`.","message":"The plugin option `emitHtml` was renamed to `emitHtmlFiles` in `v0.3.3`. Older configurations using `emitHtml` will no longer function correctly.","severity":"breaking","affected_versions":">=0.3.3"},{"fix":"Ensure all `entrypoints` paths provided in the plugin configuration correctly reference files within the `build/` output directory, typically `build/_dist_/`.","message":"The `entrypoints` option is required and expects paths relative to your Snowpack `build/` directory (e.g., `build/_dist_/index.js`), not your source `src/` directory. Providing `src/` paths will result in files not being found.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Run `npm install --save-dev rollup snowpack` or `yarn add --dev rollup snowpack` to install the peer dependencies.","message":"Both `rollup` and `snowpack` are peer dependencies. They must be installed separately in your project alongside `snowpack-plugin-rollup-bundle` for the plugin to function.","severity":"gotcha","affected_versions":">=0.3.2"},{"fix":"For new projects, consider modern build tools like Vite. For existing projects, be aware of the limited ongoing support for the Snowpack ecosystem.","message":"Snowpack, the host tool for this plugin, is largely unmaintained by its original creators, who now recommend migration to Vite. This plugin is primarily for existing Snowpack projects and is unlikely to receive significant new features or extensive support.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Upgrade to `v0.4.4` or later to ensure proper functionality on Windows.","message":"Early versions (prior to `v0.4.4`) had issues with path resolution on Windows operating systems due to incorrect path separators. This was fixed in `v0.4.4`.","severity":"gotcha","affected_versions":"<0.4.4"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Install Rollup: `npm install --save-dev rollup` or `yarn add --dev rollup`.","cause":"The 'rollup' package, a peer dependency, has not been installed in your project.","error":"Error: Cannot find module 'rollup'"},{"fix":"Adjust the `entrypoints` in your `snowpack.config.js` to point to the built files, e.g., `\"build/_dist_/index.js\"`.","cause":"The `entrypoints` option specifies a path from the source directory (`src/`) instead of the Snowpack build output directory (`build/_dist_/`).","error":"Error: [snowpack-plugin-rollup-bundle] Entrypoint 'src/index.js' not found. Entrypoints must refer to the build/ directory."},{"fix":"Initialize the `plugins` array if it doesn't exist before pushing to it: `config.inputOptions.plugins = config.inputOptions.plugins || []; config.inputOptions.plugins.push(yourPlugin());`","cause":"Attempting to push to `config.inputOptions.plugins` or `config.outputOptions.plugins` when the `plugins` array does not exist or is undefined in the default config.","error":"TypeError: Cannot read properties of undefined (reading 'push') when extending Rollup config"}],"ecosystem":"npm"}