@@ -6,9 +6,6 @@ import MiniCssExtractPlugin from 'mini-css-extract-plugin';
6
6
import { normalizeCondition } from 'webpack/lib/RuleSet' ;
7
7
import { logger } from '@storybook/node-logger' ;
8
8
9
- const JSCONFIG = 'jsconfig.json' ;
10
- const TSCONFIG = 'tsconfig.json' ;
11
-
12
9
const appDirectory = fs . realpathSync ( process . cwd ( ) ) ;
13
10
const cssExtensions = [ '.css' , '.scss' , '.sass' ] ;
14
11
const cssModuleExtensions = [ '.module.css' , '.module.scss' , '.module.sass' ] ;
@@ -114,23 +111,6 @@ export const getTypeScriptRules = (webpackConfigRules: RuleSetRule[], configDir:
114
111
} , [ ] as RuleSetRule [ ] ) ;
115
112
} ;
116
113
117
- export const getModulePath = ( ) => {
118
- // As with CRA, we only support `jsconfig.json` if `tsconfig.json` doesn't exist.
119
- let configName ;
120
- if ( fs . existsSync ( path . join ( appDirectory , TSCONFIG ) ) ) {
121
- configName = TSCONFIG ;
122
- } else if ( fs . existsSync ( path . join ( appDirectory , JSCONFIG ) ) ) {
123
- configName = JSCONFIG ;
124
- }
125
-
126
- if ( configName ) {
127
- // eslint-disable-next-line import/no-dynamic-require,global-require
128
- const config = require ( path . join ( appDirectory , configName ) ) ;
129
- return config . compilerOptions && config . compilerOptions . baseUrl ;
130
- }
131
- return false ;
132
- } ;
133
-
134
114
function mergePlugins ( basePlugins : Plugin [ ] , additionalPlugins : Plugin [ ] ) {
135
115
return [ ...basePlugins , ...additionalPlugins ] . reduce ( ( plugins , plugin ) => {
136
116
if (
@@ -171,10 +151,6 @@ export function applyCRAWebpackConfig(baseConfig: Configuration, configDir: stri
171
151
const tsExtensions = hasTsSupport ? typeScriptExtensions : [ ] ;
172
152
const extensions = [ ...cssExtensions , ...tsExtensions ] ;
173
153
174
- // Support for this was added in `[email protected] `.
175
- // https://github.com/facebook/create-react-app/pull/6656
176
- const modulePath = isReactScriptsInstalled ( '3.0.0' ) && getModulePath ( ) ;
177
-
178
154
// Remove any rules from baseConfig that test true for any one of the extensions
179
155
const filteredBaseRules = baseConfig . module . rules . filter (
180
156
rule => ! rule . test || ! extensions . some ( normalizeCondition ( rule . test ) )
@@ -205,7 +181,13 @@ export function applyCRAWebpackConfig(baseConfig: Configuration, configDir: stri
205
181
resolve : {
206
182
...baseConfig . resolve ,
207
183
extensions : [ ...baseConfig . resolve . extensions , ...tsExtensions ] ,
208
- modules : baseConfig . resolve . modules . concat ( modulePath || [ ] ) ,
184
+ modules : Array . from (
185
+ new Set ( [ ...baseConfig . resolve . modules , ...( craWebpackConfig . resolve . modules || [ ] ) ] )
186
+ ) ,
187
+ alias : {
188
+ ...baseConfig . resolve . alias ,
189
+ ...craWebpackConfig . resolve . alias ,
190
+ } ,
209
191
} ,
210
192
resolveLoader : {
211
193
modules : [ 'node_modules' , path . join ( getReactScriptsPath ( ) , 'node_modules' ) ] ,
0 commit comments