@seamlessdocs/payment-modals 1.0.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/.babelrc +13 -0
  2. package/.eslintrc.json +11 -0
  3. package/.idea/PaymentModals.iml +8 -0
  4. package/.idea/codeStyles/Project.xml +44 -0
  5. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  6. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  7. package/.idea/misc.xml +6 -0
  8. package/.idea/modules.xml +8 -0
  9. package/.idea/vcs.xml +6 -0
  10. package/.prettierrc +4 -0
  11. package/README.md +1 -0
  12. package/build/payment-modals.js +52 -0
  13. package/config/env.js +93 -0
  14. package/config/jest/cssTransform.js +14 -0
  15. package/config/jest/fileTransform.js +40 -0
  16. package/config/modules.js +88 -0
  17. package/config/paths.js +90 -0
  18. package/config/pnpTs.js +35 -0
  19. package/config/webpack.config.js +656 -0
  20. package/config/webpackDevServer.config.js +104 -0
  21. package/index.css +11 -0
  22. package/index.html +137 -0
  23. package/package.json +58 -0
  24. package/scripts/build.js +191 -0
  25. package/scripts/start.js +145 -0
  26. package/scripts/test.js +53 -0
  27. package/src/Components/ACHPaymentModal/ACHPaymentModal.module.css +118 -0
  28. package/src/Components/ACHPaymentModal/Form/FieldContainer/FieldContainer.module.css +40 -0
  29. package/src/Components/ACHPaymentModal/Form/FieldContainer/index.jsx +60 -0
  30. package/src/Components/ACHPaymentModal/Form/Form.module.css +81 -0
  31. package/src/Components/ACHPaymentModal/Form/index.jsx +189 -0
  32. package/src/Components/ACHPaymentModal/index.jsx +83 -0
  33. package/src/Components/ChooseModal/ChooseModal.module.css +114 -0
  34. package/src/Components/ChooseModal/index.jsx +34 -0
  35. package/src/Components/EmptyModal/index.jsx +7 -0
  36. package/src/Components/ErrorModal/ErrorModal.module.css +64 -0
  37. package/src/Components/ErrorModal/index.jsx +35 -0
  38. package/src/Components/ErrorOptionalModal/index.jsx +9 -0
  39. package/src/Components/Modal/Modal.module.css +29 -0
  40. package/src/Components/Modal/index.jsx +13 -0
  41. package/src/Components/PayNowModal/index.jsx +27 -0
  42. package/src/Components/ProcessingModal/ProcessingModal.module.css +50 -0
  43. package/src/Components/ProcessingModal/index.jsx +25 -0
  44. package/src/Components/SelectPaymentModal/SelectPaymentModal.module.css +212 -0
  45. package/src/Components/SelectPaymentModal/index.jsx +117 -0
  46. package/src/Components/SuccessModal/SuccessModal.module.css +34 -0
  47. package/src/Components/SuccessModal/index.jsx +23 -0
  48. package/src/OpenViewStyles.css +16 -0
  49. package/src/assets/img/back.svg +3 -0
  50. package/src/assets/img/bank-account.svg +7 -0
  51. package/src/assets/img/credit-card.svg +36 -0
  52. package/src/assets/img/error-icon.svg +1 -0
  53. package/src/assets/img/error.svg +3 -0
  54. package/src/assets/img/loader.svg +3 -0
  55. package/src/assets/img/lock-icon.svg +3 -0
  56. package/src/assets/img/logo.svg +6 -0
  57. package/src/assets/img/processing.gif +0 -0
  58. package/src/assets/img/success.svg +4 -0
  59. package/src/assets/img/valid-icon.svg +1 -0
  60. package/src/index.jsx +93 -0
  61. package/webpack.config.js +78 -0
@@ -0,0 +1,656 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const isWsl = require('is-wsl');
5
+ const path = require('path');
6
+ const webpack = require('webpack');
7
+ const resolve = require('resolve');
8
+ const PnpWebpackPlugin = require('pnp-webpack-plugin');
9
+ const HtmlWebpackPlugin = require('html-webpack-plugin');
10
+ const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
11
+ const InlineChunkHtmlPlugin = require('react-dev-utils/InlineChunkHtmlPlugin');
12
+ const TerserPlugin = require('terser-webpack-plugin');
13
+ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
14
+ const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
15
+ const safePostCssParser = require('postcss-safe-parser');
16
+ const ManifestPlugin = require('webpack-manifest-plugin');
17
+ const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
18
+ const WorkboxWebpackPlugin = require('workbox-webpack-plugin');
19
+ const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
20
+ const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
21
+ const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent');
22
+ const paths = require('./paths');
23
+ const modules = require('./modules');
24
+ const getClientEnvironment = require('./env');
25
+ const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin');
26
+ const ForkTsCheckerWebpackPlugin = require('react-dev-utils/ForkTsCheckerWebpackPlugin');
27
+ const typescriptFormatter = require('react-dev-utils/typescriptFormatter');
28
+ const eslint = require('eslint');
29
+
30
+ const postcssNormalize = require('postcss-normalize');
31
+
32
+ const appPackageJson = require(paths.appPackageJson);
33
+
34
+ // Source maps are resource heavy and can cause out of memory issue for large source files.
35
+ const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
36
+ // Some apps do not need the benefits of saving a web request, so not inlining the chunk
37
+ // makes for a smoother build process.
38
+ const shouldInlineRuntimeChunk = process.env.INLINE_RUNTIME_CHUNK !== 'false';
39
+
40
+ const imageInlineSizeLimit = parseInt(
41
+ process.env.IMAGE_INLINE_SIZE_LIMIT || '10000'
42
+ );
43
+
44
+ // Check if TypeScript is setup
45
+ const useTypeScript = fs.existsSync(paths.appTsConfig);
46
+
47
+ // style files regexes
48
+ const cssRegex = /\.css$/;
49
+ const cssModuleRegex = /\.module\.css$/;
50
+ const sassRegex = /\.(scss|sass)$/;
51
+ const sassModuleRegex = /\.module\.(scss|sass)$/;
52
+
53
+ // This is the production and development configuration.
54
+ // It is focused on developer experience, fast rebuilds, and a minimal bundle.
55
+ module.exports = function(webpackEnv) {
56
+ const isEnvDevelopment = webpackEnv === 'development';
57
+ const isEnvProduction = webpackEnv === 'production';
58
+
59
+ // Webpack uses `publicPath` to determine where the app is being served from.
60
+ // It requires a trailing slash, or the file assets will get an incorrect path.
61
+ // In development, we always serve from the root. This makes config easier.
62
+ const publicPath = isEnvProduction
63
+ ? paths.servedPath
64
+ : isEnvDevelopment && '/';
65
+ // Some apps do not use client-side routing with pushState.
66
+ // For these, "homepage" can be set to "." to enable relative asset paths.
67
+ const shouldUseRelativeAssetPaths = publicPath === './';
68
+
69
+ // `publicUrl` is just like `publicPath`, but we will provide it to our app
70
+ // as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
71
+ // Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz.
72
+ const publicUrl = isEnvProduction
73
+ ? publicPath.slice(0, -1)
74
+ : isEnvDevelopment && '';
75
+ // Get environment variables to inject into our app.
76
+ const env = getClientEnvironment(publicUrl);
77
+
78
+ // common function to get style loaders
79
+ const getStyleLoaders = (cssOptions, preProcessor) => {
80
+ const loaders = [
81
+ isEnvDevelopment && require.resolve('style-loader'),
82
+ isEnvProduction && {
83
+ loader: MiniCssExtractPlugin.loader,
84
+ options: shouldUseRelativeAssetPaths ? { publicPath: '../../' } : {},
85
+ },
86
+ {
87
+ loader: require.resolve('css-loader'),
88
+ options: cssOptions,
89
+ },
90
+ {
91
+ // Options for PostCSS as we reference these options twice
92
+ // Adds vendor prefixing based on your specified browser support in
93
+ // package.json
94
+ loader: require.resolve('postcss-loader'),
95
+ options: {
96
+ // Necessary for external CSS imports to work
97
+ // https://github.com/facebook/create-react-app/issues/2677
98
+ ident: 'postcss',
99
+ plugins: () => [
100
+ require('postcss-flexbugs-fixes'),
101
+ require('postcss-preset-env')({
102
+ autoprefixer: {
103
+ flexbox: 'no-2009',
104
+ },
105
+ stage: 3,
106
+ }),
107
+ // Adds PostCSS Normalize as the reset css with default options,
108
+ // so that it honors browserslist config in package.json
109
+ // which in turn let's users customize the target behavior as per their needs.
110
+ postcssNormalize(),
111
+ ],
112
+ sourceMap: isEnvProduction && shouldUseSourceMap,
113
+ },
114
+ },
115
+ ].filter(Boolean);
116
+ if (preProcessor) {
117
+ loaders.push(
118
+ {
119
+ loader: require.resolve('resolve-url-loader'),
120
+ options: {
121
+ sourceMap: isEnvProduction && shouldUseSourceMap,
122
+ },
123
+ },
124
+ {
125
+ loader: require.resolve(preProcessor),
126
+ options: {
127
+ sourceMap: true,
128
+ },
129
+ }
130
+ );
131
+ }
132
+ return loaders;
133
+ };
134
+
135
+ return {
136
+ mode: isEnvProduction ? 'production' : isEnvDevelopment && 'development',
137
+ // Stop compilation early in production
138
+ bail: isEnvProduction,
139
+ devtool: isEnvProduction
140
+ ? shouldUseSourceMap
141
+ ? 'source-map'
142
+ : false
143
+ : isEnvDevelopment && 'cheap-module-source-map',
144
+ // These are the "entry points" to our application.
145
+ // This means they will be the "root" imports that are included in JS bundle.
146
+ entry: [
147
+ // Include an alternative client for WebpackDevServer. A client's job is to
148
+ // connect to WebpackDevServer by a socket and get notified about changes.
149
+ // When you save a file, the client will either apply hot updates (in case
150
+ // of CSS changes), or refresh the page (in case of JS changes). When you
151
+ // make a syntax error, this client will display a syntax error overlay.
152
+ // Note: instead of the default WebpackDevServer client, we use a custom one
153
+ // to bring better experience for Create React App users. You can replace
154
+ // the line below with these two lines if you prefer the stock client:
155
+ // require.resolve('webpack-dev-server/client') + '?/',
156
+ // require.resolve('webpack/hot/dev-server'),
157
+ isEnvDevelopment &&
158
+ require.resolve('react-dev-utils/webpackHotDevClient'),
159
+ // Finally, this is your app's code:
160
+ paths.appIndexJs,
161
+ // We include the app code last so that if there is a runtime error during
162
+ // initialization, it doesn't blow up the WebpackDevServer client, and
163
+ // changing JS code would still trigger a refresh.
164
+ ].filter(Boolean),
165
+ output: {
166
+ // The build folder.
167
+ path: isEnvProduction ? paths.appBuild : undefined,
168
+ // Add /* filename */ comments to generated require()s in the output.
169
+ pathinfo: isEnvDevelopment,
170
+ // There will be one main bundle, and one file per asynchronous chunk.
171
+ // In development, it does not produce real files.
172
+ filename: isEnvProduction
173
+ ? 'static/js/[name].[contenthash:8].js'
174
+ : isEnvDevelopment && 'static/js/bundle.js',
175
+ // TODO: remove this when upgrading to webpack 5
176
+ futureEmitAssets: true,
177
+ // There are also additional JS chunk files if you use code splitting.
178
+ chunkFilename: isEnvProduction
179
+ ? 'static/js/[name].[contenthash:8].chunk.js'
180
+ : isEnvDevelopment && 'static/js/[name].chunk.js',
181
+ // We inferred the "public path" (such as / or /my-project) from homepage.
182
+ // We use "/" in development.
183
+ publicPath: publicPath,
184
+ // Point sourcemap entries to original disk location (format as URL on Windows)
185
+ devtoolModuleFilenameTemplate: isEnvProduction
186
+ ? info =>
187
+ path
188
+ .relative(paths.appSrc, info.absoluteResourcePath)
189
+ .replace(/\\/g, '/')
190
+ : isEnvDevelopment &&
191
+ (info => path.resolve(info.absoluteResourcePath).replace(/\\/g, '/')),
192
+ // Prevents conflicts when multiple Webpack runtimes (from different apps)
193
+ // are used on the same page.
194
+ jsonpFunction: `webpackJsonp${appPackageJson.name}`,
195
+ },
196
+ optimization: {
197
+ minimize: isEnvProduction,
198
+ minimizer: [
199
+ // This is only used in production mode
200
+ new TerserPlugin({
201
+ terserOptions: {
202
+ parse: {
203
+ // We want terser to parse ecma 8 code. However, we don't want it
204
+ // to apply any minification steps that turns valid ecma 5 code
205
+ // into invalid ecma 5 code. This is why the 'compress' and 'output'
206
+ // sections only apply transformations that are ecma 5 safe
207
+ // https://github.com/facebook/create-react-app/pull/4234
208
+ ecma: 8,
209
+ },
210
+ compress: {
211
+ ecma: 5,
212
+ warnings: false,
213
+ // Disabled because of an issue with Uglify breaking seemingly valid code:
214
+ // https://github.com/facebook/create-react-app/issues/2376
215
+ // Pending further investigation:
216
+ // https://github.com/mishoo/UglifyJS2/issues/2011
217
+ comparisons: false,
218
+ // Disabled because of an issue with Terser breaking valid code:
219
+ // https://github.com/facebook/create-react-app/issues/5250
220
+ // Pending further investigation:
221
+ // https://github.com/terser-js/terser/issues/120
222
+ inline: 2,
223
+ },
224
+ mangle: {
225
+ safari10: true,
226
+ },
227
+ output: {
228
+ ecma: 5,
229
+ comments: false,
230
+ // Turned on because emoji and regex is not minified properly using default
231
+ // https://github.com/facebook/create-react-app/issues/2488
232
+ ascii_only: true,
233
+ },
234
+ },
235
+ // Use multi-process parallel running to improve the build speed
236
+ // Default number of concurrent runs: os.cpus().length - 1
237
+ // Disabled on WSL (Windows Subsystem for Linux) due to an issue with Terser
238
+ // https://github.com/webpack-contrib/terser-webpack-plugin/issues/21
239
+ parallel: !isWsl,
240
+ // Enable file caching
241
+ cache: true,
242
+ sourceMap: shouldUseSourceMap,
243
+ }),
244
+ // This is only used in production mode
245
+ new OptimizeCSSAssetsPlugin({
246
+ cssProcessorOptions: {
247
+ parser: safePostCssParser,
248
+ map: shouldUseSourceMap
249
+ ? {
250
+ // `inline: false` forces the sourcemap to be output into a
251
+ // separate file
252
+ inline: false,
253
+ // `annotation: true` appends the sourceMappingURL to the end of
254
+ // the css file, helping the browser find the sourcemap
255
+ annotation: true,
256
+ }
257
+ : false,
258
+ },
259
+ }),
260
+ ],
261
+ // Automatically split vendor and commons
262
+ // https://twitter.com/wSokra/status/969633336732905474
263
+ // https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
264
+ splitChunks: {
265
+ chunks: 'all',
266
+ name: false,
267
+ },
268
+ // Keep the runtime chunk separated to enable long term caching
269
+ // https://twitter.com/wSokra/status/969679223278505985
270
+ // https://github.com/facebook/create-react-app/issues/5358
271
+ runtimeChunk: {
272
+ name: entrypoint => `runtime-${entrypoint.name}`,
273
+ },
274
+ },
275
+ resolve: {
276
+ // This allows you to set a fallback for where Webpack should look for modules.
277
+ // We placed these paths second because we want `node_modules` to "win"
278
+ // if there are any conflicts. This matches Node resolution mechanism.
279
+ // https://github.com/facebook/create-react-app/issues/253
280
+ modules: ['node_modules', paths.appNodeModules].concat(
281
+ modules.additionalModulePaths || []
282
+ ),
283
+ // These are the reasonable defaults supported by the Node ecosystem.
284
+ // We also include JSX as a common component filename extension to support
285
+ // some tools, although we do not recommend using it, see:
286
+ // https://github.com/facebook/create-react-app/issues/290
287
+ // `web` extension prefixes have been added for better support
288
+ // for React Native Web.
289
+ extensions: paths.moduleFileExtensions
290
+ .map(ext => `.${ext}`)
291
+ .filter(ext => useTypeScript || !ext.includes('ts')),
292
+ alias: {
293
+ // Support React Native Web
294
+ // https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
295
+ 'react-native': 'react-native-web',
296
+ },
297
+ plugins: [
298
+ // Adds support for installing with Plug'n'Play, leading to faster installs and adding
299
+ // guards against forgotten dependencies and such.
300
+ PnpWebpackPlugin,
301
+ // Prevents users from importing files from outside of src/ (or node_modules/).
302
+ // This often causes confusion because we only process files within src/ with babel.
303
+ // To fix this, we prevent you from importing files out of src/ -- if you'd like to,
304
+ // please link the files into your node_modules/ and let module-resolution kick in.
305
+ // Make sure your source files are compiled, as they will not be processed in any way.
306
+ new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]),
307
+ ],
308
+ },
309
+ resolveLoader: {
310
+ plugins: [
311
+ // Also related to Plug'n'Play, but this time it tells Webpack to load its loaders
312
+ // from the current package.
313
+ PnpWebpackPlugin.moduleLoader(module),
314
+ ],
315
+ },
316
+ module: {
317
+ strictExportPresence: true,
318
+ rules: [
319
+ // Disable require.ensure as it's not a standard language feature.
320
+ { parser: { requireEnsure: false } },
321
+
322
+ // First, run the linter.
323
+ // It's important to do this before Babel processes the JS.
324
+ {
325
+ test: /\.(js|mjs|jsx|ts|tsx)$/,
326
+ enforce: 'pre',
327
+ use: [
328
+ {
329
+ options: {
330
+ cache: true,
331
+ formatter: require.resolve('react-dev-utils/eslintFormatter'),
332
+ eslintPath: require.resolve('eslint'),
333
+ resolvePluginsRelativeTo: __dirname,
334
+
335
+ },
336
+ loader: require.resolve('eslint-loader'),
337
+ },
338
+ ],
339
+ include: paths.appSrc,
340
+ },
341
+ {
342
+ // "oneOf" will traverse all following loaders until one will
343
+ // match the requirements. When no loader matches it will fall
344
+ // back to the "file" loader at the end of the loader list.
345
+ oneOf: [
346
+ // "url" loader works like "file" loader except that it embeds assets
347
+ // smaller than specified limit in bytes as data URLs to avoid requests.
348
+ // A missing `test` is equivalent to a match.
349
+ {
350
+ test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
351
+ loader: require.resolve('url-loader'),
352
+ options: {
353
+ limit: imageInlineSizeLimit,
354
+ name: 'static/media/[name].[hash:8].[ext]',
355
+ },
356
+ },
357
+ // Process application JS with Babel.
358
+ // The preset includes JSX, Flow, TypeScript, and some ESnext features.
359
+ {
360
+ test: /\.(js|mjs|jsx|ts|tsx)$/,
361
+ include: paths.appSrc,
362
+ loader: require.resolve('babel-loader'),
363
+ options: {
364
+ customize: require.resolve(
365
+ 'babel-preset-react-app/webpack-overrides'
366
+ ),
367
+
368
+ plugins: [
369
+ [
370
+ require.resolve('babel-plugin-named-asset-import'),
371
+ {
372
+ loaderMap: {
373
+ svg: {
374
+ ReactComponent:
375
+ '@svgr/webpack?-svgo,+titleProp,+ref![path]',
376
+ },
377
+ },
378
+ },
379
+ ],
380
+ ],
381
+ // This is a feature of `babel-loader` for webpack (not Babel itself).
382
+ // It enables caching results in ./node_modules/.cache/babel-loader/
383
+ // directory for faster rebuilds.
384
+ cacheDirectory: true,
385
+ // See #6846 for context on why cacheCompression is disabled
386
+ cacheCompression: false,
387
+ compact: isEnvProduction,
388
+ },
389
+ },
390
+ // Process any JS outside of the app with Babel.
391
+ // Unlike the application JS, we only compile the standard ES features.
392
+ {
393
+ test: /\.(js|mjs)$/,
394
+ exclude: /@babel(?:\/|\\{1,2})runtime/,
395
+ loader: require.resolve('babel-loader'),
396
+ options: {
397
+ babelrc: false,
398
+ configFile: false,
399
+ compact: false,
400
+ presets: [
401
+ [
402
+ require.resolve('babel-preset-react-app/dependencies'),
403
+ { helpers: true },
404
+ ],
405
+ ],
406
+ cacheDirectory: true,
407
+ // See #6846 for context on why cacheCompression is disabled
408
+ cacheCompression: false,
409
+
410
+ // If an error happens in a package, it's possible to be
411
+ // because it was compiled. Thus, we don't want the browser
412
+ // debugger to show the original code. Instead, the code
413
+ // being evaluated would be much more helpful.
414
+ sourceMaps: false,
415
+ },
416
+ },
417
+ // "postcss" loader applies autoprefixer to our CSS.
418
+ // "css" loader resolves paths in CSS and adds assets as dependencies.
419
+ // "style" loader turns CSS into JS modules that inject <style> tags.
420
+ // In production, we use MiniCSSExtractPlugin to extract that CSS
421
+ // to a file, but in development "style" loader enables hot editing
422
+ // of CSS.
423
+ // By default we support CSS Modules with the extension .module.css
424
+ {
425
+ test: cssRegex,
426
+ exclude: cssModuleRegex,
427
+ use: getStyleLoaders({
428
+ importLoaders: 1,
429
+ sourceMap: isEnvProduction && shouldUseSourceMap,
430
+ }),
431
+ // Don't consider CSS imports dead code even if the
432
+ // containing package claims to have no side effects.
433
+ // Remove this when webpack adds a warning or an error for this.
434
+ // See https://github.com/webpack/webpack/issues/6571
435
+ sideEffects: true,
436
+ },
437
+ // Adds support for CSS Modules (https://github.com/css-modules/css-modules)
438
+ // using the extension .module.css
439
+ {
440
+ test: cssModuleRegex,
441
+ use: getStyleLoaders({
442
+ importLoaders: 1,
443
+ sourceMap: isEnvProduction && shouldUseSourceMap,
444
+ modules: true,
445
+ getLocalIdent: getCSSModuleLocalIdent,
446
+ }),
447
+ },
448
+ // Opt-in support for SASS (using .scss or .sass extensions).
449
+ // By default we support SASS Modules with the
450
+ // extensions .module.scss or .module.sass
451
+ {
452
+ test: sassRegex,
453
+ exclude: sassModuleRegex,
454
+ use: getStyleLoaders(
455
+ {
456
+ importLoaders: 2,
457
+ sourceMap: isEnvProduction && shouldUseSourceMap,
458
+ },
459
+ 'sass-loader'
460
+ ),
461
+ // Don't consider CSS imports dead code even if the
462
+ // containing package claims to have no side effects.
463
+ // Remove this when webpack adds a warning or an error for this.
464
+ // See https://github.com/webpack/webpack/issues/6571
465
+ sideEffects: true,
466
+ },
467
+ // Adds support for CSS Modules, but using SASS
468
+ // using the extension .module.scss or .module.sass
469
+ {
470
+ test: sassModuleRegex,
471
+ use: getStyleLoaders(
472
+ {
473
+ importLoaders: 2,
474
+ sourceMap: isEnvProduction && shouldUseSourceMap,
475
+ modules: true,
476
+ getLocalIdent: getCSSModuleLocalIdent,
477
+ },
478
+ 'sass-loader'
479
+ ),
480
+ },
481
+ // "file" loader makes sure those assets get served by WebpackDevServer.
482
+ // When you `import` an asset, you get its (virtual) filename.
483
+ // In production, they would get copied to the `build` folder.
484
+ // This loader doesn't use a "test" so it will catch all modules
485
+ // that fall through the other loaders.
486
+ {
487
+ loader: require.resolve('file-loader'),
488
+ // Exclude `js` files to keep "css" loader working as it injects
489
+ // its runtime that would otherwise be processed through "file" loader.
490
+ // Also exclude `html` and `json` extensions so they get processed
491
+ // by webpacks internal loaders.
492
+ exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/],
493
+ options: {
494
+ name: 'static/media/[name].[hash:8].[ext]',
495
+ },
496
+ },
497
+ // ** STOP ** Are you adding a new loader?
498
+ // Make sure to add the new loader(s) before the "file" loader.
499
+ ],
500
+ },
501
+ ],
502
+ },
503
+ plugins: [
504
+ // Generates an `index.html` file with the <script> injected.
505
+ new HtmlWebpackPlugin(
506
+ Object.assign(
507
+ {},
508
+ {
509
+ inject: true,
510
+ template: paths.appHtml,
511
+ },
512
+ isEnvProduction
513
+ ? {
514
+ minify: {
515
+ removeComments: true,
516
+ collapseWhitespace: true,
517
+ removeRedundantAttributes: true,
518
+ useShortDoctype: true,
519
+ removeEmptyAttributes: true,
520
+ removeStyleLinkTypeAttributes: true,
521
+ keepClosingSlash: true,
522
+ minifyJS: true,
523
+ minifyCSS: true,
524
+ minifyURLs: true,
525
+ },
526
+ }
527
+ : undefined
528
+ )
529
+ ),
530
+ // Inlines the webpack runtime script. This script is too small to warrant
531
+ // a network request.
532
+ // https://github.com/facebook/create-react-app/issues/5358
533
+ isEnvProduction &&
534
+ shouldInlineRuntimeChunk &&
535
+ new InlineChunkHtmlPlugin(HtmlWebpackPlugin, [/runtime-.+[.]js/]),
536
+ // Makes some environment variables available in index.html.
537
+ // The public URL is available as %PUBLIC_URL% in index.html, e.g.:
538
+ // <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
539
+ // In production, it will be an empty string unless you specify "homepage"
540
+ // in `package.json`, in which case it will be the pathname of that URL.
541
+ // In development, this will be an empty string.
542
+ new InterpolateHtmlPlugin(HtmlWebpackPlugin, env.raw),
543
+ // This gives some necessary context to module not found errors, such as
544
+ // the requesting resource.
545
+ new ModuleNotFoundPlugin(paths.appPath),
546
+ // Makes some environment variables available to the JS code, for example:
547
+ // if (process.env.NODE_ENV === 'production') { ... }. See `./env.js`.
548
+ // It is absolutely essential that NODE_ENV is set to production
549
+ // during a production build.
550
+ // Otherwise React will be compiled in the very slow development mode.
551
+ new webpack.DefinePlugin(env.stringified),
552
+ // This is necessary to emit hot updates (currently CSS only):
553
+ isEnvDevelopment && new webpack.HotModuleReplacementPlugin(),
554
+ // Watcher doesn't work well if you mistype casing in a path so we use
555
+ // a plugin that prints an error when you attempt to do this.
556
+ // See https://github.com/facebook/create-react-app/issues/240
557
+ isEnvDevelopment && new CaseSensitivePathsPlugin(),
558
+ // If you require a missing module and then `npm install` it, you still have
559
+ // to restart the development server for Webpack to discover it. This plugin
560
+ // makes the discovery automatic so you don't have to restart.
561
+ // See https://github.com/facebook/create-react-app/issues/186
562
+ isEnvDevelopment &&
563
+ new WatchMissingNodeModulesPlugin(paths.appNodeModules),
564
+ isEnvProduction &&
565
+ new MiniCssExtractPlugin({
566
+ // Options similar to the same options in webpackOptions.output
567
+ // both options are optional
568
+ filename: 'static/css/[name].[contenthash:8].css',
569
+ chunkFilename: 'static/css/[name].[contenthash:8].chunk.css',
570
+ }),
571
+ // Generate a manifest file which contains a mapping of all asset filenames
572
+ // to their corresponding output file so that tools can pick it up without
573
+ // having to parse `index.html`.
574
+ new ManifestPlugin({
575
+ fileName: 'asset-manifest.json',
576
+ publicPath: publicPath,
577
+ generate: (seed, files) => {
578
+ const manifestFiles = files.reduce(function(manifest, file) {
579
+ manifest[file.name] = file.path;
580
+ return manifest;
581
+ }, seed);
582
+
583
+ return {
584
+ files: manifestFiles,
585
+ };
586
+ },
587
+ }),
588
+ // Moment.js is an extremely popular library that bundles large locale files
589
+ // by default due to how Webpack interprets its code. This is a practical
590
+ // solution that requires the user to opt into importing specific locales.
591
+ // https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
592
+ // You can remove this if you don't use Moment.js:
593
+ new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
594
+ // Generate a service worker script that will precache, and keep up to date,
595
+ // the HTML & assets that are part of the Webpack build.
596
+ isEnvProduction &&
597
+ new WorkboxWebpackPlugin.GenerateSW({
598
+ clientsClaim: true,
599
+ exclude: [/\.map$/, /asset-manifest\.json$/],
600
+ importWorkboxFrom: 'cdn',
601
+ navigateFallback: publicUrl + '/index.html',
602
+ navigateFallbackBlacklist: [
603
+ // Exclude URLs starting with /_, as they're likely an API call
604
+ new RegExp('^/_'),
605
+ // Exclude any URLs whose last part seems to be a file extension
606
+ // as they're likely a resource and not a SPA route.
607
+ // URLs containing a "?" character won't be blacklisted as they're likely
608
+ // a route with query params (e.g. auth callbacks).
609
+ new RegExp('/[^/?]+\\.[^/]+$'),
610
+ ],
611
+ }),
612
+ // TypeScript type checking
613
+ useTypeScript &&
614
+ new ForkTsCheckerWebpackPlugin({
615
+ typescript: resolve.sync('typescript', {
616
+ basedir: paths.appNodeModules,
617
+ }),
618
+ async: isEnvDevelopment,
619
+ useTypescriptIncrementalApi: true,
620
+ checkSyntacticErrors: true,
621
+ resolveModuleNameModule: process.versions.pnp
622
+ ? `${__dirname}/pnpTs.js`
623
+ : undefined,
624
+ resolveTypeReferenceDirectiveModule: process.versions.pnp
625
+ ? `${__dirname}/pnpTs.js`
626
+ : undefined,
627
+ tsconfig: paths.appTsConfig,
628
+ reportFiles: [
629
+ '**',
630
+ '!**/__tests__/**',
631
+ '!**/?(*.)(spec|test).*',
632
+ '!**/src/setupProxy.*',
633
+ '!**/src/setupTests.*',
634
+ ],
635
+ silent: true,
636
+ // The formatter is invoked directly in WebpackDevServerUtils during development
637
+ formatter: isEnvProduction ? typescriptFormatter : undefined,
638
+ }),
639
+ ].filter(Boolean),
640
+ // Some libraries import Node modules but don't use them in the browser.
641
+ // Tell Webpack to provide empty mocks for them so importing them works.
642
+ node: {
643
+ module: 'empty',
644
+ dgram: 'empty',
645
+ dns: 'mock',
646
+ fs: 'empty',
647
+ http2: 'empty',
648
+ net: 'empty',
649
+ tls: 'empty',
650
+ child_process: 'empty',
651
+ },
652
+ // Turn off performance processing because we utilize
653
+ // our own hints via the FileSizeReporter
654
+ performance: false,
655
+ };
656
+ };