Skip to content

Instantly share code, notes, and snippets.

@evolify
Created June 15, 2022 02:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evolify/147ec48de8da45d04a26ef8785a56cd8 to your computer and use it in GitHub Desktop.
Save evolify/147ec48de8da45d04a26ef8785a56cd8 to your computer and use it in GitHub Desktop.
Rollup config for js and ts
{
"name": "",
"version": "0.1.0",
"description": "",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
}
},
"scripts": {
"build": "rollup -c"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"esbuild": "^0.14.43",
"rollup": "^2.75.6",
"rollup-plugin-dts": "^4.2.2",
"rollup-plugin-esbuild": "^4.9.1",
"typescript": "^4.7.3"
}
}
import { defineConfig } from "rollup"
import esbuild from "rollup-plugin-esbuild"
import dts from "rollup-plugin-dts"
const name = require("./package.json").main.replace(/\.js$/, "")
export default defineConfig([
{
input: "src/index.ts",
plugins: [esbuild()],
output: [
{
file: `${name}.js`,
format: "cjs",
sourcemap: true,
},
{
file: `${name}.mjs`,
format: "es",
sourcemap: true,
},
],
},
{
input: "src/index.ts",
plugins: [dts()],
output: {
file: `${name}.d.ts`,
format: "es",
},
},
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment