-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathcraco.config.js
190 lines (184 loc) · 6.25 KB
/
craco.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
const {
addBeforeLoader,
loaderByName,
when,
whenDev,
whenProd,
whenTest,
ESLINT_MODES,
POSTCSS_MODES
} = require('@craco/craco');
const path = require('path');
module.exports = {
// reactScriptsVersion: 'react-scripts' /* (default value) */,
// style: {
// modules: {
// localIdentName: ''
// },
// css: {
// loaderOptions: {
// /* Any css-loader configuration options: https://github.com/webpack-contrib/css-loader. */
// },
// loaderOptions: (cssLoaderOptions, {env, paths}) => {
// return cssLoaderOptions;
// }
// },
// sass: {
// loaderOptions: {
// /* Any sass-loader configuration options: https://github.com/webpack-contrib/sass-loader. */
// },
// loaderOptions: (sassLoaderOptions, {env, paths}) => {
// return sassLoaderOptions;
// }
// },
// postcss: {
// mode: 'extends' /* (default value) */ || 'file',
// plugins: [require('plugin-to-append')], // Additional plugins given in an array are appended to existing config.
// plugins: (plugins) => [require('plugin-to-prepend')].concat(plugins), // Or you may use the function variant.
// env: {
// autoprefixer: {
// /* Any autoprefixer options: https://github.com/postcss/autoprefixer#options */
// },
// stage: 3 /* Any valid stages: https://cssdb.org/#staging-process. */,
// features: {
// /* Any CSS features: https://preset-env.cssdb.org/features. */
// }
// },
// loaderOptions: {
// /* Any postcss-loader configuration options: https://github.com/postcss/postcss-loader. */
// },
// loaderOptions: (postcssLoaderOptions, {env, paths}) => {
// return postcssLoaderOptions;
// }
// }
// },
// eslint: {
// enable: true /* (default value) */,
// mode: 'extends' /* (default value) */ || 'file',
// configure: {
// /* Any eslint configuration options: https://eslint.org/docs/user-guide/configuring */
// },
// configure: (eslintConfig, {env, paths}) => {
// return eslintConfig;
// },
// pluginOptions: {
// /* Any eslint plugin configuration options: https://github.com/webpack-contrib/eslint-webpack-plugin#options. */
// },
// pluginOptions: (eslintOptions, {env, paths}) => {
// return eslintOptions;
// }
// },
babel: {
presets: [
// The 'metro-react-native-babel-preset' preset is recommended to match React Native's packager
['module:metro-react-native-babel-preset', {useTransformReactJSXExperimental: true}]
],
plugins: [
// https://necolas.github.io/react-native-web/docs/setup/#package-optimization
'react-native-web',
[
// Enable new JSX Transform from React
'@babel/plugin-transform-react-jsx',
{
runtime: 'automatic'
}
]
],
loaderOptions: {
/* Any babel-loader configuration options: https://github.com/babel/babel-loader. */
}
// loaderOptions: (babelLoaderOptions, {env, paths}) => {
// return babelLoaderOptions;
// }
},
// typescript: {
// enableTypeChecking: true /* (default value) */
// },
webpack: {
alias: {
['@invertase/react-native-apple-authentication$']: path.resolve(
__dirname,
'src/shims/react-native-apple-authentication-web.ts'
),
['@react-native-firebase/app$']: path.resolve(__dirname, 'src/shims/firebase-app-web.ts'),
['@react-native-firebase/analytics$']: path.resolve(__dirname, 'src/shims/firebase-analytics-web.ts'),
['@react-native-firebase/auth$']: path.resolve(__dirname, 'src/shims/firebase-auth-web.ts'),
['@react-native-firebase/firestore$']: path.resolve(__dirname, 'src/shims/firebase-firestore-web.ts'),
['@react-native-google-signin/google-signin$']: path.resolve(__dirname, 'src/shims/google-signin-web.ts'),
['react-native-fbsdk-next$']: path.resolve(__dirname, 'src/shims/react-native-fbsdk-next-web.ts')
},
plugins: {
add: [] /* An array of plugins */,
add: [
// plugin1,
// [plugin2, 'append'],
// [plugin3, 'prepend'] /* Specify if plugin should be appended or prepended */
] /* An array of plugins */,
remove: [] /* An array of plugin constructor's names (i.e. "StyleLintPlugin", "ESLintWebpackPlugin" ) */
},
configure: {
/* Any webpack configuration options: https://webpack.js.org/configuration */
},
configure: (webpackConfig, {env, paths}) => {
const imageLoader = {
test: /\.(gif|jpe?g|png|svg)$/,
use: {
loader: 'url-loader',
options: {
name: '[name].[ext]',
esModule: false
}
}
};
addBeforeLoader(webpackConfig, loaderByName('url-loader'), imageLoader);
return webpackConfig;
}
},
// jest: {
// babel: {
// addPresets: true /* (default value) */,
// addPlugins: true /* (default value) */
// },
// configure: {
// /* Any Jest configuration options: https://jestjs.io/docs/en/configuration. */
// },
// configure: (jestConfig, {env, paths, resolve, rootDir}) => {
// return jestConfig;
// }
// },
// devServer: {
// /* Any devServer configuration options: https://webpack.js.org/configuration/dev-server/#devserver. */
// },
// devServer: (devServerConfig, {env, paths, proxy, allowedHost}) => {
// return devServerConfig;
// },
plugins: [
{
plugin: {
// overrideCracoConfig: ({cracoConfig, pluginOptions, context: {env, paths}}) => {
// return cracoConfig;
// },
overrideWebpackConfig: ({webpackConfig, cracoConfig, pluginOptions, context: {env, paths}}) => {
return webpackConfig;
}
// overrideDevServerConfig: ({
// devServerConfig,
// cracoConfig,
// pluginOptions,
// context: {env, paths, proxy, allowedHost}
// }) => {
// return devServerConfig;
// },
// overrideJestConfig: ({
// jestConfig,
// cracoConfig,
// pluginOptions,
// context: {env, paths, resolve, rootDir}
// }) => {
// return jestConfig;
// }
}
// options: {}
}
]
};