66 lines
2.1 KiB
JavaScript
66 lines
2.1 KiB
JavaScript
import ts from "rollup-plugin-ts"
|
||
import resolve from '@rollup/plugin-node-resolve';
|
||
import commonjs from '@rollup/plugin-commonjs';
|
||
import { terser } from 'rollup-plugin-terser'
|
||
import nodePolyfills from 'rollup-plugin-polyfill-node'
|
||
import serve from 'rollup-plugin-serve';
|
||
import bable from 'rollup-plugin-babel'
|
||
|
||
|
||
export default {
|
||
input: "./src/index.ts",
|
||
plugins: [
|
||
bable({
|
||
exclude:'node_modules'
|
||
}),
|
||
nodePolyfills(),//打包node内置模块,浏览器端使用,如events
|
||
resolve({ browser: true }),//加载第三方模块
|
||
commonjs(),//common转esm
|
||
ts({ tsconfig: "tsconfig.json" }),//typescript support
|
||
terser(), //minify the code and remove comments
|
||
process.env.ENV === "development" ? serve({
|
||
port: 13200,
|
||
contentBase: ["example", "."], // 静态资源所在目录
|
||
}) : null
|
||
],
|
||
output: [
|
||
{
|
||
format: "umd",//umd format
|
||
file: "dist/index.js", //output
|
||
name: "UscRtc", //name of umd
|
||
exports: "named",//remove export default warning
|
||
sourcemap: true
|
||
},
|
||
{
|
||
format: "esm",//esm format
|
||
file: "dist/index.esm.js",//output file
|
||
sourcemap: true
|
||
},
|
||
{
|
||
format: "cjs",//umd format
|
||
file: "dist/index.cjs.js", //output
|
||
name: "bundleName", //name of umd
|
||
exports: "named",//remove export default warning
|
||
sourcemap: true
|
||
},
|
||
{
|
||
format: "umd",//umd format
|
||
file: "example/index.js", //打包到示例demo中
|
||
name: "UscRtc", //name of umd
|
||
exports: "named",//remove export default warning
|
||
sourcemap: true
|
||
},
|
||
{
|
||
format: "esm",//esm format
|
||
file: "example/index.esm.js",//打包到示例demo中
|
||
sourcemap: true
|
||
}, {
|
||
format: "cjs",//umd format
|
||
file: "example/index.cjs.js", //output
|
||
name: "bundleName", //name of umd
|
||
exports: "named",//remove export default warning
|
||
sourcemap: true
|
||
},
|
||
],
|
||
}
|