@vinicius73/rollup-plugin-skypack-resolver
v2.1.2
Published
Generate the bundle of your project using Skypack CDN for external dependencies.
Downloads
12
Maintainers
Readme
@vinicius73/rollup-plugin-skypack-resolver
Generate the bundle of your project using Skypack CDN for external dependencies.
Install
yarn add @vinicius73/rollup-plugin-skypack-resolver rollup -D
Usage
On this example, axios and lodash-es need be installed as project dependencies, using npm or yarn.
skypackResolver
uses your local dependencies to determine cdn version.
//> rollup.config.js
const { skypackResolver } = require('@vinicius73/rollup-plugin-skypack-resolver')
module.exports = {
input: 'src/index.js',
output: {
format: 'es'
},
plugins: [skypackResolver({
modules: ['axios', 'lodash-es']
})]
}
//> src/index.js
import axios from 'axios'
import { get } from 'lodash-es'
const run = async () => {
const { data } = await axios.get('https://reqres.in/api/users/2')
console.log(
get(data, ['data', 'email'])
)
}
run()
.then(() => console.log('All done'))
.catch(err => console.error(err))
rullup -c
//> output
import axios from 'https://cdn.skypack.dev/[email protected]';
import { get } from 'https://cdn.skypack.dev/[email protected]';
const run = async () => {
const { data } = await axios.get('https://reqres.in/api/users/2');
console.log(get(data, ['data', 'email']));
};
run()
.then(() => console.log('All done'))
.catch(err => console.error(err));
Options
modules
Type: Array[...String]
Required: true
An array with modules that will be transformed into cdn import.
cdnHost
Type: String
Required: false
Default: https://cdn.skypack.dev
Host used in imports.