Created
May 15, 2023 23:11
-
-
Save angusdev/9b3f777544cdca0a79e75db32dca433b to your computer and use it in GitHub Desktop.
Sample Rollup Project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm install --save-dev rollup rollup-plugin-node-resolve rollup-plugin-commonjs rollup-plugin-babel @babel/preset-env | |
npm run build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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