Last active
July 29, 2022 08:02
-
-
Save clukhei/ef1e21cb38e11524bbcb02c9cf11dbb7 to your computer and use it in GitHub Desktop.
Subpath Imports Rollup plugins
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 peerDepsExternal from "rollup-plugin-peer-deps-external"; | |
import resolve from "@rollup/plugin-node-resolve"; | |
import commonjs from "@rollup/plugin-commonjs"; | |
import typescript from "rollup-plugin-typescript2"; | |
import replace from "@rollup/plugin-replace"; | |
import { terser } from "rollup-plugin-terser"; | |
const packageJson = require("./package.json"); | |
import generatePackageJson from "rollup-plugin-generate-package-json"; | |
const plugins = [ | |
peerDepsExternal(), | |
resolve(), | |
replace({ | |
__IS_DEV__: process.env.NODE_ENV === "development", | |
}), | |
commonjs(), | |
typescript({ | |
tsconfig: "./tsconfig.json", | |
useTsconfigDeclarationDir: true, | |
}), | |
terser(), | |
]; | |
const subfolderPlugins = (folderName) => [ | |
...plugins, | |
generatePackageJson({ | |
baseContents: { | |
name: `${packageJson.name}/${folderName}`, | |
private: true, | |
main: "../cjs/index.js", // --> points to cjs format entry point of whole library | |
module: "./index.js", // --> points to esm format entry point of individual component | |
types: "./index.d.ts", // --> points to types definition file of individual component | |
}, | |
}), | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment