Skip to content

Instantly share code, notes, and snippets.

@angusdev
Created May 15, 2023 23:11
Show Gist options
  • Save angusdev/9b3f777544cdca0a79e75db32dca433b to your computer and use it in GitHub Desktop.
Save angusdev/9b3f777544cdca0a79e75db32dca433b to your computer and use it in GitHub Desktop.
Sample Rollup Project
npm install --save-dev rollup rollup-plugin-node-resolve rollup-plugin-commonjs rollup-plugin-babel @babel/preset-env
npm run build
{
"name": "sample-library",
"version": "1.0.0",
"description": "A sample Node.js library",
"main": "index.js",
"scripts": {
"build": "rollup -c"
},
"author": "Your Name",
"license": "MIT"
}
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import babel from 'rollup-plugin-babel';
export default {
input: 'src/index.js', // Specify the entry point of your library
output: {
file: 'dist/bundle.js', // Specify the name and location of the bundled file
format: 'umd', // Choose the desired module format (e.g., UMD)
name: 'SampleLibrary', // Specify the global variable name if your library is used in a non-module environment
sourcemap: true, // Generate sourcemaps for debugging
},
plugins: [
resolve(),
commonjs(),
babel({
exclude: 'node_modules/**',
presets: ['@babel/preset-env'],
}),
],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment