rollup-plugin-cdn-upload

1.0.5 • Public • Published

rollup-plugin-cdn-upload

A Rollup plugin which parsing local assets,upload it to cdn and replace the source[html | chunks],also support Vite

Install

npm install rollup-plugin-cdn-upload --save-dev

Usage

import cdnUpload from "rollup-plugin-cdn-upload";

export default {
  input: "src/index.js",
  output: {
    dir: "output",
    format: "cjs",
  },
  plugins: [
    cdnUpload({
      uploader: (content, ext) => {
        return Promise.resolve("");
      },
    }),
  ],
};

for vite,base must set '' (default is /)

export default defineConfig({
  base: "",
  build: {
    rollupOptions: {
      plugins: [
        cdnUpload({
          uploader: (content, ext) => {
            return Promise.resolve("");
          },
        }),
      ],
    },
  },
});

Options

uploader

  • Type: function(content,ext):<Promise>
  • Default:
    (content: sourceCode, ext: type) => {
      return Promise.resolve("");
    };
    your cdn upload function with current upload source code and type ext. the funtion return a Promise with final url resolved

keepSource

  • Type: boolean
  • Default: false

keep uploaded modules or not

cacheDir

  • Type: string
  • Default: ./dist_cdn

the response url will cached in this directory

output

  • Type: string
  • Default: ./dist_cdn

output directory

Readme

Keywords

Package Sidebar

Install

npm i rollup-plugin-cdn-upload

Weekly Downloads

0

Version

1.0.5

License

MIT

Unpacked Size

9.57 kB

Total Files

3

Last publish

Collaborators

  • iryn