This repository was archived by the owner on Dec 28, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.mjs
More file actions
152 lines (149 loc) · 4.75 KB
/
rollup.config.mjs
File metadata and controls
152 lines (149 loc) · 4.75 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// rollup.config.mjs
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import babel from '@rollup/plugin-babel';
import terser from "@rollup/plugin-terser";
import postcss from 'rollup-plugin-postcss';
import image from '@rollup/plugin-image';
import pkg from './package.json' assert { type: "json" };
import json from '@rollup/plugin-json';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import rollupPostcssLessLoader from 'rollup-plugin-postcss-webpack-alias-less-loader';
import postcssUrl from 'postcss-url';
import esbuild from 'rollup-plugin-esbuild';
import url from '@rollup/plugin-url';
import path from 'path';
// import nodePolyfills from 'rollup-plugin-node-polyfills';
// export default {
// input: 'src/index.js',
// output: {
// name: pkg.name,
// file: 'lib/bundle.js',
// format: 'umd',
// globals: {
// 'qs': 'qs',
// 'axios': 'axios'
// }
// },
// plugins: [
// resolve(), // so Rollup can find `ms`
// babel({ exclude: 'node_modules/**', extensions: ['.js', '.jsx'] }), // so Rollup can transpile JSX and TS
// commonjs(), // so Rollup can convert `ms` to an ES module
// postcss({modules: true}),
// image(),
// // terser() // so Rollup can minify the output
// ]
// };
export default {
input: [
'./src/index.js',
],
output: [{
file: 'lib/bundle.js',
assetFileNames: '[name]-[hash][extname]',
exports: 'named',
format: 'umd',
name: '@baidu/hugegraph-analysis-react',
externalLiveBindings: false,
freeze: false,
globals: {
'react': 'React',
'prop-types': 'PropTypes',
'react-router-dom': 'ReactRouterDOM',
'react-dom': 'ReactDOM',
'axios': 'axios',
'react-router': 'ReactRouter',
'dayjs': 'dayjs',
'@baidu/spui': 'BaiduSpui',
'query-string': 'qs',
'classnames': 'classnames',
'vis-network': 'VisNetwork',
'crypto-js': 'CryptoJS',
'@antv/graphin': 'Graphin',
}
}],
plugins: [
peerDepsExternal(),
// nodePolyfills(),
resolve({
browser: true,
jsnext: true,
main: true,
preferBuiltins: true,
extensions: ['.js', '.jsx', '.ts', '.tsx', '.mjs'],
skip: [
'react',
'react-dom',
'prop-types',
'react-router',
'react-router-dom',
// 'axios'
],
}),
url({
fileName: '[name][extname]',
reserveImportInJs: true
}),
esbuild({
// All options are optional
include: /\.[jt]sx?$/, // default, inferred from `loaders` option
exclude: /node_modules/, // default
sourceMap: false, // by default inferred from rollup's `output.sourcemap` option
minify: process.env.NODE_ENV === 'production',
target: 'es2017', // default, or 'es20XX', 'esnext'
jsx: 'transform', // default, or 'preserve'
jsxFactory: 'React.createElement',
jsxFragment: 'React.Fragment',
// Like @rollup/plugin-replace
define: {
__VERSION__: '"x.y.z"',
},
tsconfig: 'tsconfig.json', // default
// Add extra loaders
loaders: {
// Add .json files support
// require @rollup/plugin-commonjs
'.json': 'json',
// Enable JSX in .js files too
'.js': 'jsx',
},
}),
// css
// postcss({
// loaders: [
// rollupPostcssLessLoader({
// nodeModulePath: path.resolve('node_modules'),
// aliases: {}
// })
// ],
// extract: path.resolve('dist/index.css'),
// minimize: true,
// use: [
// [
// 'less',
// {
// javascriptEnabled: true
// }
// ]
// ],
// plugins: [
// postcssUrl({
// url: 'inline',
// assetsPath: 'img',
// maxSize: 10, // maximum file size to inline (in kilobytes)
// fallback: 'copy',
// })
// ]
// }),
json(),
postcss({modules: true}),
commonjs(),
],
external: [
'react',
'react-dom',
'prop-types',
'react-router',
'react-router-dom',
],
}