Skip to content

Instantly share code, notes, and snippets.

@geotrev
Last active February 3, 2022 01:02
Show Gist options
  • Save geotrev/8c2ca91b109c4ed88141d4732a8303c0 to your computer and use it in GitHub Desktop.
Save geotrev/8c2ca91b109c4ed88141d4732a8303c0 to your computer and use it in GitHub Desktop.
Jekyll Rollup Config
import { terser } from "rollup-plugin-terser"
import path from "path"
import resolve from "rollup-plugin-node-resolve"
import babel from "rollup-plugin-babel"
import glob from "glob"
const scriptPattern = path.resolve(__dirname, "_scripts/**/!(_)*.js")
const inputs = glob.sync(scriptPattern).reduce((files, input) => {
const parts = input.split("/")
const fileKey = parts[parts.length - 1]
return { [fileKey]: input, ...files }
}, {})
const outputs = Object.keys(inputs).reduce((files, file) => {
const inputPath = inputs[file]
const parts = inputPath.split("/")
const pathIndex = parts.indexOf("_scripts") + 1
const outputPath = parts.slice(pathIndex).join("/")
return { [file]: `assets/js/${outputPath}`, ...files }
}, {})
const bundles = Object.keys(inputs).map(key => {
return {
input: inputs[key],
output: {
file: outputs[key],
format: "umd",
sourcemap: true,
},
plugins: [
resolve(),
babel({
exclude: "node_modules/**",
comments: false,
}),
terser(),
],
}
})
export default bundles
@mavaddat
Copy link

import babel from "rollup-plugin-babel"

is now

import { babel } from '@rollup/plugin-babel';

See Migration to @rollup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment