1.1.2 • Published 5 years ago
rollup-plugin-skypin v1.1.2
rollup-plugin-skypin
🍣 A Rollup plugin which converts NodeJS imports into URL's from skypack.dev. Based on skypin.
Install
Using npm:
npm install rollup-plugin-skypin --save-devUsage
Suppose an input file containing the snippet below exists at src/index.js, and attempts to load hueman:
src/index.js (input file)
// src/index.js
import { hueman } from 'hueman';
console.log(hueman(100,1.0,0.5));Create a rollup.config.js configuration file and import the plugin:
rollup.config.js (input file)
import { skypin } from 'rollup-plugin-skypin';
export default {
input: 'src/index.js',
output: {
file: 'dist/index.js',
format: 'esm'
},
// ...
plugins: [
skypin()
]
};Then call rollup either via the CLI or the API.
dist/index.js (example output file)
import { hueman } from 'https://cdn.skypack.dev/pin/hueman@v2.1.1-ElNqhC8YFxLlgRtjjL9o/min/hueman.js';
console.log(hueman(100,1.0,0.5))Options
The options object can be used to customize the behavior of this plugin
options.minified:boolean(defaults totrue). Based on normal vs. minified in skypack lookup pageoptions.pinned:boolean(default totrue). Whether to use Pinned url's (recommended for production). Read more hereoptions.shouldReplace():function(id) => boolean|string(default to()=>true). Customize which module ID's to replace using skypin. If a string is returned, it will be used as id.options.relative_external:boolean(defaults tofalse). Whether to return relative exports (ex:./supporting_file.js) asexternaloptions.web_external:boolean(defaults totrue). Whether to mark existing web imports (starting with "https://" or "http://") asexternalto be ignored.
License
MIT © Marshall Brandt