rollup-plugin-unpkg

A rollup plugin to convert ES imports to UNPKG urls.

MIT 4 个版本
安装
npm install rollup-plugin-unpkg
yarn add rollup-plugin-unpkg
pnpm add rollup-plugin-unpkg
bun add rollup-plugin-unpkg
README

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/superfine@6.0.1?type=module';
import store from 'https://unpkg.com/@vanillajs/store@0.1.7?type=module';

Inspiration

Inspired from this twitter conversation and a follow up gist

版本列表
0.1.0 2021-02-27
0.0.3 2019-04-14
0.0.2 2019-04-14
0.0.1 2019-04-14