-
Notifications
You must be signed in to change notification settings - Fork 555
Expand file tree
/
Copy pathrollup.config.mjs
More file actions
67 lines (60 loc) · 1.43 KB
/
rollup.config.mjs
File metadata and controls
67 lines (60 loc) · 1.43 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
import {
createESMConfig,
createCJSConfig,
createUMDConfig,
createBanner,
collectSourceEntries,
} from '../../scripts/build/rollup.base.mjs';
import pkg from './package.json' with { type: 'json' };
const moduleInput = collectSourceEntries();
const umdInput = 'src/index.ts';
const isESM = process.env.BUILD_FORMAT === 'esm';
const isCJS = process.env.BUILD_FORMAT === 'cjs';
const isUMD = process.env.BUILD_FORMAT === 'umd';
const banner = createBanner({
name: 'React InstantSearch',
version: pkg.version,
});
// When BUILD_FORMAT is set, only build that format
// Otherwise, build all (for watch mode)
const configs = [];
if (isESM || (!isESM && !isCJS && !isUMD)) {
configs.push(
createESMConfig({
input: moduleInput,
pkg,
outputDir: 'dist/es',
preserveModules: true,
})
);
}
if (isCJS || (!isESM && !isCJS && !isUMD)) {
configs.push(
createCJSConfig({
input: moduleInput,
pkg,
outputDir: 'dist/cjs',
preserveModules: true,
replaceImports: {
'instantsearch.js/es': 'instantsearch.js/cjs',
},
})
);
}
if (isUMD || (!isESM && !isCJS && !isUMD)) {
configs.push(
...createUMDConfig({
input: umdInput,
pkg,
name: 'ReactInstantSearch',
banner,
outputDir: 'dist/umd',
fileName: 'ReactInstantSearch',
legacyFileNames: true,
globals: {
react: 'React',
},
})
);
}
export default configs;