forked from adazzle/react-data-grid
-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.js
53 lines (51 loc) · 1.46 KB
/
rollup.config.js
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
import { isAbsolute } from 'path';
import linaria from '@linaria/rollup';
import postcss from 'rollup-plugin-postcss';
import postcssNested from 'postcss-nested';
import { babel } from '@rollup/plugin-babel';
import nodeResolve from '@rollup/plugin-node-resolve';
import pkg from './package.json';
const extensions = ['.ts', '.tsx'];
export default {
input: './src/index.ts',
output: [
{
file: './lib/bundle.js',
format: 'es',
generatedCode: 'es2015',
sourcemap: true
},
{
file: './lib/bundle.cjs',
format: 'cjs',
generatedCode: 'es2015',
sourcemap: true,
interop: false
}
],
external: (id) => !id.startsWith('.') && !id.startsWith('@linaria:') && !isAbsolute(id),
plugins: [
linaria({
preprocessor: 'none',
classNameSlug(hash) {
// We add the package version as suffix to avoid style conflicts
// between multiple versions of RDG on the same page.
return `${hash}${pkg.version.replaceAll('.', '')}`;
}
}),
postcss({
plugins: [postcssNested],
minimize: true,
inject: { insertAt: 'top' }
}),
babel({
babelHelpers: 'runtime',
extensions,
// remove all comments except terser annotations
// https://github.com/terser/terser#annotations
// https://babeljs.io/docs/en/options#shouldprintcomment
shouldPrintComment: (comment) => /^[@#]__.+__$/.test(comment)
}),
nodeResolve({ extensions })
]
};