1
- const path = require ( 'path' ) ;
2
- const PATHS = require ( '../config/paths' ) ;
3
- require ( 'dotenv' ) . config ( {
1
+ import path from 'path' ;
2
+ import PATHS from '../config/paths' ;
3
+
4
+ import { config } from 'dotenv' ;
5
+ config ( {
4
6
path : path . join ( PATHS . root , '.env' )
5
7
} ) ;
6
8
@@ -10,81 +12,80 @@ const DEPENDENCY_REGEX = BUILD_FOR_IE11
10
12
? / n o d e _ m o d u l e s /
11
13
: / n o d e _ m o d u l e s \/ ( @ u i 5 \/ w e b c o m p o n e n t s ( - ( b a s e | c o r e | f i o r i | i c o n s | t h e m e - b a s e ) ) ? | l i t - h t m l ) \/ / ;
12
14
13
- module . exports = {
14
- stories : [ '../docs/**/*.stories.mdx' , '../packages/**/*.stories.@(tsx|jsx|mdx)' ] ,
15
- addons : [
16
- '@storybook/addon-toolbars' ,
17
- '@storybook/addon-docs' ,
18
- '@storybook/addon-controls' ,
19
- '@storybook/addon-actions'
20
- ] ,
21
- webpack : async ( config , { configType } ) => {
22
- // `configType` has a value of 'DEVELOPMENT' or 'PRODUCTION'
23
- // You can change the configuration based on that.
24
- // 'PRODUCTION' is used when building the static version of storybook.
15
+ export const stories = [ '../docs/**/*.stories.mdx' , '../packages/**/*.stories.@(tsx|jsx|mdx)' ] ;
25
16
26
- config . module . rules . push ( {
27
- test : / a s s e t s \/ .* \. j s o n $ / ,
28
- use : 'file-loader' ,
29
- type : 'javascript/auto'
30
- } ) ;
17
+ export const addons = [
18
+ '@storybook/addon-toolbars' ,
19
+ '@storybook/addon-docs' ,
20
+ '@storybook/addon-controls' ,
21
+ '@storybook/addon-actions'
22
+ ] ;
23
+ export async function webpack ( config , { configType } ) {
24
+ // `configType` has a value of 'DEVELOPMENT' or 'PRODUCTION'
25
+ // You can change the configuration based on that.
26
+ // 'PRODUCTION' is used when building the static version of storybook.
31
27
32
- if ( configType === 'PRODUCTION' || BUILD_FOR_IE11 ) {
33
- config . module . rules . push ( {
34
- test : / \. ( j s | m j s ) $ / ,
35
- include : DEPENDENCY_REGEX ,
36
- loader : 'babel-loader' ,
37
- options : {
38
- sourceType : 'unambiguous' ,
39
- babelrc : false ,
40
- configFile : false ,
41
- compact : false ,
42
- presets : [
43
- [
44
- '@babel/preset-env' ,
45
- {
46
- // Allow importing core-js in entrypoint and use browserlist to select polyfills
47
- useBuiltIns : 'entry' ,
48
- // Set the corejs version we are using to avoid warnings in console
49
- // This will need to change once we upgrade to corejs@3
50
- corejs : 3 ,
51
- // Do not transform modules to CJS
52
- modules : false ,
53
- // Exclude transforms that make all code slower
54
- exclude : [ 'transform-typeof-symbol' ]
55
- }
56
- ]
57
- ] ,
58
- plugins : [
59
- [
60
- '@babel/plugin-transform-runtime' ,
61
- {
62
- version : require ( '@babel/runtime/package.json' ) . version ,
63
- useESModules : true
64
- }
65
- ]
66
- ] ,
67
- cacheDirectory : true ,
68
- cacheCompression : false ,
28
+ config . module . rules . push ( {
29
+ test : / a s s e t s \/ .* \. j s o n $ / ,
30
+ use : 'file-loader' ,
31
+ type : 'javascript/auto'
32
+ } ) ;
69
33
70
- // If an error happens in a package, it's possible to be
71
- // because it was compiled. Thus, we don't want the browser
72
- // debugger to show the original code. Instead, the code
73
- // being evaluated would be much more helpful.
74
- sourceMaps : false
75
- }
76
- } ) ;
77
- }
78
- config . resolve . alias = {
79
- ...config . resolve . alias ,
80
- '@shared' : path . join ( PATHS . root , 'shared' ) ,
81
- '@ui5/webcomponents-react/dist' : path . join ( PATHS . root , 'packages' , 'main' , 'dist' ) ,
82
- '@ui5/webcomponents-react' : path . join ( PATHS . root , 'packages' , 'main' , 'src' ) ,
83
- '@ui5/webcomponents-react-charts' : path . join ( PATHS . root , 'packages' , 'charts' , 'src' ) ,
84
- '@ui5/webcomponents-react-base/types' : path . join ( PATHS . root , 'packages' , 'base' , 'types' ) ,
85
- '@ui5/webcomponents-react-base' : path . join ( PATHS . root , 'packages' , 'base' , 'src' )
86
- } ;
34
+ if ( configType === 'PRODUCTION' || BUILD_FOR_IE11 ) {
35
+ config . module . rules . push ( {
36
+ test : / \. ( j s | m j s ) $ / ,
37
+ include : DEPENDENCY_REGEX ,
38
+ loader : 'babel-loader' ,
39
+ options : {
40
+ sourceType : 'unambiguous' ,
41
+ babelrc : false ,
42
+ configFile : false ,
43
+ compact : false ,
44
+ presets : [
45
+ [
46
+ '@babel/preset-env' ,
47
+ {
48
+ // Allow importing core-js in entrypoint and use browserlist to select polyfills
49
+ useBuiltIns : 'entry' ,
50
+ // Set the corejs version we are using to avoid warnings in console
51
+ // This will need to change once we upgrade to corejs@3
52
+ corejs : 3 ,
53
+ // Do not transform modules to CJS
54
+ modules : false ,
55
+ // Exclude transforms that make all code slower
56
+ exclude : [ 'transform-typeof-symbol' ]
57
+ }
58
+ ]
59
+ ] ,
60
+ plugins : [
61
+ [
62
+ '@babel/plugin-transform-runtime' ,
63
+ {
64
+ version : require ( '@babel/runtime/package.json' ) . version ,
65
+ useESModules : true
66
+ }
67
+ ]
68
+ ] ,
69
+ cacheDirectory : true ,
70
+ cacheCompression : false ,
87
71
88
- return config ;
72
+ // If an error happens in a package, it's possible to be
73
+ // because it was compiled. Thus, we don't want the browser
74
+ // debugger to show the original code. Instead, the code
75
+ // being evaluated would be much more helpful.
76
+ sourceMaps : false
77
+ }
78
+ } ) ;
89
79
}
90
- } ;
80
+ config . resolve . alias = {
81
+ ...config . resolve . alias ,
82
+ '@shared' : path . join ( PATHS . root , 'shared' ) ,
83
+ '@ui5/webcomponents-react/dist' : path . join ( PATHS . root , 'packages' , 'main' , 'dist' ) ,
84
+ '@ui5/webcomponents-react' : path . join ( PATHS . root , 'packages' , 'main' , 'src' ) ,
85
+ '@ui5/webcomponents-react-charts' : path . join ( PATHS . root , 'packages' , 'charts' , 'src' ) ,
86
+ '@ui5/webcomponents-react-base/types' : path . join ( PATHS . root , 'packages' , 'base' , 'types' ) ,
87
+ '@ui5/webcomponents-react-base' : path . join ( PATHS . root , 'packages' , 'base' , 'src' )
88
+ } ;
89
+
90
+ return config ;
91
+ }
0 commit comments