Created
June 15, 2022 02:32
-
-
Save evolify/147ec48de8da45d04a26ef8785a56cd8 to your computer and use it in GitHub Desktop.
Rollup config for js and ts
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
{ | |
"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" | |
} | |
} |
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 { 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