web-backset.cn/packages/ui/rollup.config.js

56 lines
1.4 KiB
JavaScript
Raw Normal View History

2023-02-24 18:00:48 +08:00
import resolve from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
// rollup默认不支持commonjs
import commonjs from '@rollup/plugin-commonjs';
import babel from 'rollup-plugin-babel'
import postcss from 'rollup-plugin-postcss'
import terser from '@rollup/plugin-terser';
import path, { join } from 'path'
import dts from "rollup-plugin-dts";
import { readdirSync, statSync } from 'fs'
export default [
{
input: './src/index.ts',
output: {
dir: 'dist',
format: 'esm',
entryFileNames: '[name].esm.js',
},
plugins: [
resolve(),
commonjs(),
typescript(),
// babel({ exclude: "node_modules/**", presets: ["@babel/preset-env"] }),
terser(),
postcss({
extract: true,
extract: path.resolve('dist/ui.css')
})],
},
// index.d.ts
{
input: "./src/index.ts",
output: [{ file: "dist/index.d.ts", format: "es" }],
plugins: [dts(), postcss({
extract: true,
extract: path.resolve('dist/ui.css')
})],
},
// 单独打包每个组件
// 生成 commonjs
// {
// input: 'src/index.ts',
// output: {
// dir: 'dist',
// format: 'cjs',
// entryFileNames: '[name].cjs.js',
// },
// plugins: [resolve(), commonjs(), typescript(), terser(), postcss({
// extract: true,
// minimize: true, // cssnano 压缩
// extract: path.resolve('dist/ui.css'),
// })],
// },
]