-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathrollup.config.mjs
83 lines (81 loc) · 2.79 KB
/
rollup.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import typescript from '@rollup/plugin-typescript';
import postcss from 'rollup-plugin-postcss';
// import image from '@rollup/plugin-image';
import path from 'path';
import strip from '@rollup/plugin-strip';
// import url from '@rollup/plugin-url';
import svg from 'rollup-plugin-svg';
import cssOnly from 'rollup-plugin-css-only';
import less from 'rollup-plugin-less';
import css from 'rollup-plugin-import-css';
import replace from '@rollup/plugin-replace';
import babel from '@rollup/plugin-babel';
import { terser } from 'rollup-plugin-terser';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const pkg = require('./package.json');
export default [
{
input: './index.tsx',
output: {
file: pkg.main,
// dir: path.dirname(pkg.main), // 打包输出文件保留原始模块结构
format: 'esm',
// name: pkg.name,
// exports: 'named', // 指定导出模式(自动、默认、命名、无)
// preserveModules: true, // 保留模块结构
// preserveModulesRoot: '.', // 将保留的模块放在根级别的此路径下
},
plugins: [
peerDepsExternal(),
resolve(),
commonjs({ transformMixedEsModules: true }),
// babel(),
typescript({
tsconfig: './tsconfig.json'
}),
// replace({
// "Object.defineProperty(exports, '__esModule', { value: true });": '',
// delimiters: ['\n', '\n'],
// }),
postcss({
extract: true,
}),
// image(), // 将所有图片打包成base64
// strip(), // Remove debugger statements and functions like assert.equal and console.log from your code 生产环境打开
// url(), // 将所有图片打包成js文件
svg(), // 将svg作为inline打包,dom中直接嵌入svg dom,非base64,采用image/url打成base64有部分图片展示不出来,还需要套img src标签
],
},
{
input: './index.tsx',
output: [
{
file: 'dist/quill-react-commercial.min.js',
format: 'umd',
sourcemap: true,
name: 'quillReactCommercial',
},
{
file: 'example/quill-react-commercial.min.js',
format: 'umd',
sourcemap: false,
name: 'quillReactCommercial',
}, // 给 github actions 和 github pages 使用
],
plugins: [
peerDepsExternal(),
resolve(),
commonjs(),
typescript(),
postcss({
extract: true,
}),
svg(), // 将svg作为inline打包,dom中直接嵌入svg dom,非base64,采用image/url打成base64有部分图片展示不出来,还需要套img src标签
terser(),
],
},
];