Skip to content

osdevisnot/rollup-plugin-unpkg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rollup-plugin-unpkg

A rollup plugin to convert ES imports to UNPKG urls.

Usage

Add this plugin to rollup.config.js:

const unpkg = require('rollup-plugin-unpkg');

export default {
  input: 'src/main.js',
  output: {
    file: 'bundle.js',
    format: 'cjs'
  },
  plugins: [unpkg()]
};

Example

package.json dependencies:

  "dependencies": {
    "@vanillajs/store": "^0.1.7",
    "superfine": "^6.0.1"
  },

Input Code:

import { patch, h } from 'superfine';
import store from '@vanillajs/store';

Output Code:

import { patch, h } from 'https://unpkg.com/[email protected]?type=module';
import store from 'https://unpkg.com/@vanillajs/[email protected]?type=module';

Inspiration

Inspired from this twitter conversation and a follow up gist

About

A rollup plugin to convert ES imports to UNPKG urls.

Resources

Stars

Watchers

Forks

Packages

No packages published