1- // eslint-disable-next-line
2- const crypto = require ( 'crypto' ) ; // Force method use SHA-256 to address
3- const cryptCreateHashOrig = crypto . createHash ; // OpenSSL 3.0 deprecation of
4- crypto . createHash = ( ) => cryptCreateHashOrig ( 'sha256' ) ; // MD4 algorithm
5-
6- module . exports = {
7- style : {
8- postcss : {
9- plugins : [
10- require ( 'tailwindcss' ) ,
11- require ( 'autoprefixer' ) ,
12- ] ,
13- } ,
14- } ,
15- webpack : {
16- configure : ( webpackConfig ) => {
17- webpackConfig . module . rules . push ( {
18- test : / \. y m l $ / i,
19- loader : 'raw-loader' ,
20- } ) ;
21-
22- webpackConfig . resolve . alias = webpackConfig . resolve . alias || { } ;
23- webpackConfig . resolve . alias [ 'nimma/fallbacks' ] = require . resolve ( './node_modules/nimma/dist/legacy/cjs/fallbacks/index.js' ) ;
24- webpackConfig . resolve . alias [ 'nimma/legacy' ] = require . resolve ( './node_modules/nimma/dist/legacy/cjs/index.js' ) ;
25-
26- return webpackConfig ;
1+ /* eslint-disable */
2+
3+ const crypto = require ( 'crypto' ) ;
4+ const webpack = require ( 'webpack' ) ;
5+
6+ function getFileLoaderRule ( rules ) {
7+ for ( const rule of rules ) {
8+ if ( "oneOf" in rule ) {
9+ const found = getFileLoaderRule ( rule . oneOf ) ;
10+ if ( found ) {
11+ return found ;
12+ }
13+ } else if ( rule . test === undefined && rule . type === 'asset/resource' ) {
14+ return rule ;
2715 }
2816 }
29- } ;
17+ throw new Error ( "File loader not found" ) ;
18+ }
19+
20+ function configureWebpack ( webpackConfig ) {
21+ // fallbacks
22+ const fallback = webpackConfig . resolve . fallback || { } ;
23+ Object . assign ( fallback , {
24+ assert : require . resolve ( 'assert/' ) ,
25+ buffer : require . resolve ( 'buffer' ) ,
26+ http : require . resolve ( 'stream-http' ) ,
27+ https : require . resolve ( 'https-browserify' ) ,
28+ path : require . resolve ( 'path-browserify' ) ,
29+ stream : require . resolve ( 'stream-browserify' ) ,
30+ zlib : require . resolve ( 'browserify-zlib' ) ,
31+ url : require . resolve ( 'url/' ) ,
32+ util : require . resolve ( 'util/' ) ,
33+ fs : false ,
34+ } ) ;
35+ webpackConfig . resolve . fallback = fallback ;
36+
37+ // aliases
38+ webpackConfig . resolve . alias = webpackConfig . resolve . alias || { } ;
39+ webpackConfig . resolve . alias [ 'nimma/fallbacks' ] = require . resolve ( './node_modules/nimma/dist/legacy/cjs/fallbacks/index.js' ) ;
40+ webpackConfig . resolve . alias [ 'nimma/legacy' ] = require . resolve ( './node_modules/nimma/dist/legacy/cjs/index.js' ) ;
41+
42+ // plugins
43+ webpackConfig . plugins = ( webpackConfig . plugins || [ ] ) . concat ( [
44+ new webpack . ProvidePlugin ( {
45+ process : 'process/browser.js' ,
46+ Buffer : [ 'buffer' , 'Buffer' ]
47+ } )
48+ ] ) ;
49+
50+ // rules/loaders
51+ // workaround for https://github.com/facebook/create-react-app/issues/11889 issue
52+ const fileLoaderRule = getFileLoaderRule ( webpackConfig . module . rules ) ;
53+ fileLoaderRule . exclude . push ( / \. c j s $ / ) ;
54+ webpackConfig . module . rules . push ( {
55+ test : / \. y m l $ / i,
56+ type : 'asset/source' ,
57+ } ) ;
58+
59+ // ignore source-map warnings
60+ webpackConfig . ignoreWarnings = [ ...( webpackConfig . ignoreWarnings || [ ] ) , / F a i l e d t o p a r s e s o u r c e m a p / ] ;
61+
62+ return webpackConfig ;
63+ }
64+
65+ // Force method use SHA-256 to address OpenSSL 3.0 deprecation of MD4 algorithm
66+ function configureCrypto ( ) {
67+ const cryptCreateHashOrig = crypto . createHash ;
68+ crypto . createHash = ( ) => cryptCreateHashOrig ( 'sha256' ) ;
69+ }
70+
71+ function setEnvironments ( ) {
72+ process . env . DISABLE_ESLINT_PLUGIN = true ;
73+ }
74+
75+ function configureCraco ( ) {
76+ setEnvironments ( ) ;
77+ configureCrypto ( ) ;
78+
79+ return {
80+ webpack : {
81+ configure : configureWebpack ,
82+ }
83+ } ;
84+ }
85+
86+ module . exports = configureCraco ( ) ;
0 commit comments