-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathcraco.config.js
More file actions
92 lines (87 loc) · 2.82 KB
/
craco.config.js
File metadata and controls
92 lines (87 loc) · 2.82 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
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
const CracoLessPlugin = require('craco-less');
// Tree-shake antd in webpack only; applying this in Jest breaks TS/ESM transforms.
const babelPlugins =
process.env.NODE_ENV === 'test'
? []
: [
[
'import',
{
libraryName: 'antd',
libraryDirectory: 'es',
style: false,
},
'antd',
],
];
module.exports = {
babel: {
plugins: babelPlugins,
},
plugins: [
{
plugin: CracoLessPlugin,
options: {
lessLoaderOptions: {
lessOptions: {
javascriptEnabled: true,
},
},
},
},
],
webpack: {
configure: (webpackConfig) => {
// Add rule to handle TypeScript files in node_modules
webpackConfig.module.rules.push({
test: /\.tsx?$/,
include: /node_modules\/(mapbox-pmtiles|pmtiles)/,
use: {
loader: 'babel-loader',
options: {
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
['@babel/preset-typescript', {
allowDeclareFields: true,
onlyRemoveTypeImports: true
}]
],
plugins: [
'@babel/plugin-proposal-class-properties'
]
}
}
});
// Exclude these packages from source-map-loader
const sourceMapLoaderRule = webpackConfig.module.rules.find(
rule => rule.use && rule.use.find && rule.use.find(use => use.loader && use.loader.includes('source-map-loader'))
);
if (sourceMapLoaderRule) {
sourceMapLoaderRule.exclude = [
...(sourceMapLoaderRule.exclude || []),
/node_modules\/(mapbox-pmtiles|pmtiles)/
];
}
return webpackConfig;
}
},
devServer: {
proxy: {
'/api/openrouteservice': {
target: 'https://api.openrouteservice.org',
changeOrigin: true,
pathRewrite: {
'^/api/openrouteservice': ''
},
secure: true,
logLevel: 'debug'
},
'/pmtiles': {
target: 'http://localhost:3000',
changeOrigin: true,
secure: false,
logLevel: 'debug'
}
}
}
};