1 Star 0 Fork 4

wangxf_org/fingerprintjs2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
rollup.config.ts 2.56 KB
一键复制 编辑 原始数据 按行查看 历史
import * as fs from 'fs'
import type { RollupOptions } from 'rollup'
import jsonPlugin from '@rollup/plugin-json'
import nodeResolvePlugin from '@rollup/plugin-node-resolve'
import typescriptPlugin from '@rollup/plugin-typescript'
import terserPlugin from '@rollup/plugin-terser'
import dtsPlugin from 'rollup-plugin-dts'
import licensePlugin from 'rollup-plugin-license'
import terserConfig from './terser.config'
const { dependencies } = JSON.parse(fs.readFileSync('package.json', 'utf8'))
const outputDirectory = 'dist'
const commonInput = {
input: 'src/index.ts',
plugins: [nodeResolvePlugin(), jsonPlugin(), typescriptPlugin()],
}
const commonOutput = {
name: 'FingerprintJS',
exports: 'named' as const,
plugins: [
licensePlugin({
banner: {
content: {
file: 'resources/license_banner.txt',
},
data: {
license: fs.readFileSync('LICENSE', 'utf8').trim(),
},
},
}),
],
}
const commonTerser = terserPlugin(terserConfig)
const config: RollupOptions[] = [
// Browser bundles. They have all the dependencies included for convenience.
{
...commonInput,
output: [
// IIFE for users who use Require.js or Electron and want to just call `window.FingerprintJS.load()`
{
...commonOutput,
file: `${outputDirectory}/fp.js`,
format: 'iife',
},
{
...commonOutput,
file: `${outputDirectory}/fp.min.js`,
format: 'iife',
plugins: [commonTerser, ...commonOutput.plugins],
},
// UMD for users who use Require.js or Electron and want to leverage them
{
...commonOutput,
file: `${outputDirectory}/fp.umd.js`,
format: 'umd',
},
{
...commonOutput,
file: `${outputDirectory}/fp.umd.min.js`,
format: 'umd',
plugins: [commonTerser, ...commonOutput.plugins],
},
],
},
// NPM bundles. They have all the dependencies excluded for end code size optimization.
{
...commonInput,
external: Object.keys(dependencies),
output: [
// CJS for usage with `require()`
{
...commonOutput,
file: `${outputDirectory}/fp.cjs.js`,
format: 'cjs',
},
// ESM for usage with `import`
{
...commonOutput,
file: `${outputDirectory}/fp.esm.js`,
format: 'esm',
},
],
},
// TypeScript definition
{
...commonInput,
plugins: [dtsPlugin()],
output: {
...commonOutput,
file: `${outputDirectory}/fp.d.ts`,
format: 'esm',
},
},
]
export default config
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/wangxf_org/fingerprintjs2.git
[email protected]:wangxf_org/fingerprintjs2.git
wangxf_org
fingerprintjs2
fingerprintjs2
master

搜索帮助