-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
55 lines (54 loc) · 1.34 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
54
55
import { babel } from "@rollup/plugin-babel";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import multiInput from 'rollup-plugin-multi-input'
import path from 'path'
export default {
external: [
'tty',
'os',
'path',
'fs',
'util',
'url',
'react',
'react-dom',
/@testing-library/,
/@babel\/runtime/
],
input: [
// Exempt files like example.stories.js and example.test.js
'_src/components/**/*[!.st].js'
],
output: [
{
format: 'cjs',
dir: '.',
exports: 'named'
},
],
plugins: [
nodeResolve({ preferBuiltins: false }),
commonjs({
include: /node_modules/
}),
babel({ babelHelpers: 'runtime' }),
multiInput({
relative: '_src',
transformOutputPath: function(output, input) {
const parentFolders = path.dirname(input).split(path.sep)
// Remove the src/{hooks|components} directories
let newDestination = parentFolders.slice(2, parentFolders.length)
if(parentFolders.length === 2) {
newDestination = []
}
let end = `${newDestination.join(path.sep)}/${path.basename(output)}`
if(!newDestination.length) {
end = path.basename(output)
}
return end
}
}),
],
preserveEntrySignatures: 'strict',
}