forked from boazeb/papervault
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig-overrides.js
More file actions
47 lines (43 loc) · 1.71 KB
/
Copy pathconfig-overrides.js
File metadata and controls
47 lines (43 loc) · 1.71 KB
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
/* config-overrides.js */
const webpack = require('webpack');
module.exports = function override(config, env) {
//do stuff with the webpack config...
// Webpack 5 ESM resolution doesn't add .js; packages like @react-pdf/renderer
// request 'react/jsx-runtime' and fail. Alias to in-src shims that re-export (avoids ModuleScopePlugin).
const path = require('path');
const paths = require('react-scripts/config/paths');
config.resolve.alias = {
...(config.resolve.alias || {}),
'react/jsx-runtime': path.join(paths.appSrc, 'react-jsx-runtime.js'),
'react/jsx-dev-runtime': path.join(paths.appSrc, 'react-jsx-dev-runtime.js'),
};
config.resolve.fallback = {
url: require.resolve('url'),
assert: require.resolve('assert'),
crypto: require.resolve('crypto-browserify'),
http: require.resolve('stream-http'),
https: require.resolve('https-browserify'),
os: require.resolve('os-browserify/browser'),
buffer: require.resolve('buffer'),
stream: require.resolve('stream-browserify'),
vm: require.resolve('vm-browserify'),
'process/browser': require.resolve('process/browser'),
};
config.plugins.push(
new webpack.ProvidePlugin({
process: 'process/browser',
Buffer: ['buffer', 'Buffer'],
}),
);
//bb: fix to resolve issue with pdfjs not working... something to do with webpack and poyfills.
config.module.rules.push({
test: /\.(js|mjs|jsx)$/,
enforce: 'pre',
loader: require.resolve('source-map-loader'),
exclude: /node_modules/,
resolve: {
fullySpecified: false,
},
});
return config;
};