1
+ const copy = require ( 'rollup-plugin-copy' ) ;
2
+
3
+ module . exports = ( rollupConfig , _projectOptions ) => {
4
+ rollupConfig . input = {
5
+ index : 'packages/storybook-addon/src/index.ts' ,
6
+ preset : 'packages/storybook-addon/preset.ts' ,
7
+ } ;
8
+
9
+ rollupConfig . plugins . push (
10
+ copy ( {
11
+ targets : [
12
+ { src : 'packages/storybook-addon/README.md' , dest : 'packages/storybook-addon/dist' } ,
13
+ { src : 'packages/storybook-addon/LICENSE' , dest : 'packages/storybook-addon/dist' } ,
14
+ ] ,
15
+ } ) ,
16
+ ) ;
17
+
18
+ rollupConfig . external = [
19
+ / @ m o d u l e - f e d e r a t i o n / ,
20
+ / @ s t o r y b o o k / ,
21
+ / @ r s b u i l d / ,
22
+ / @ n x / ,
23
+ 'webpack' ,
24
+ 'webpack-virtual-modules' ,
25
+ ] ;
26
+
27
+ if ( Array . isArray ( rollupConfig . output ) ) {
28
+ rollupConfig . output = rollupConfig . output . map ( ( c ) => ( {
29
+ ...c ,
30
+ hoistTransitiveImports : false ,
31
+ entryFileNames :
32
+ c . format === 'cjs'
33
+ ? c . entryFileNames . replace ( '.js' , '.cjs' )
34
+ : c . entryFileNames ,
35
+ chunkFileNames :
36
+ c . format === 'cjs'
37
+ ? c . chunkFileNames . replace ( '.js' , '.cjs' )
38
+ : c . chunkFileNames ,
39
+ ...( c . format === 'cjs' ? { externalLiveBindings : false } : { } ) ,
40
+ } ) ) ;
41
+ } else {
42
+ rollupConfig . output = {
43
+ ...rollupConfig . output ,
44
+ hoistTransitiveImports : false ,
45
+ entryFileNames :
46
+ rollupConfig . output . format === 'cjs'
47
+ ? rollupConfig . output . entryFileNames . replace ( '.js' , '.cjs' )
48
+ : rollupConfig . output . entryFileNames ,
49
+ chunkFileNames :
50
+ rollupConfig . output . format === 'cjs'
51
+ ? rollupConfig . output . chunkFileNames . replace ( '.js' , '.cjs' )
52
+ : rollupConfig . output . chunkFileNames ,
53
+ ...( rollupConfig . output . format === 'cjs'
54
+ ? { externalLiveBindings : false }
55
+ : { } ) ,
56
+ } ;
57
+ }
58
+
59
+ return rollupConfig ;
60
+ } ;
0 commit comments