Last active
February 3, 2022 01:02
-
-
Save geotrev/8c2ca91b109c4ed88141d4732a8303c0 to your computer and use it in GitHub Desktop.
Jekyll Rollup Config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
is now
See Migration to @rollup