-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcraco.config.js
More file actions
45 lines (41 loc) · 1.13 KB
/
craco.config.js
File metadata and controls
45 lines (41 loc) · 1.13 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
module.exports = {
devServer: {
proxy: {
'/api/show-my-ip': {
target: 'https://api.ipify.org',
changeOrigin: true,
pathRewrite: { '^/api/show-my-ip': '' },
},
},
setupMiddlewares: (middlewares, devServer) => {
if (!devServer) {
throw new Error('webpack-dev-server is not defined');
}
devServer.app.use((req, res, next) => {
if (req.path.endsWith('.piml')) {
res.set('Content-Type', 'text/plain');
}
next();
});
return middlewares;
},
},
webpack: {
configure: (webpackConfig, { env, paths }) => {
// Disable sourcemaps for production
if (env === 'production') {
webpackConfig.devtool = false;
}
// Add a rule to ignore source map warnings from node_modules
webpackConfig.module.rules.push({
test: /\.js$/,
enforce: 'pre',
use: ['source-map-loader'],
exclude: /node_modules/,
});
// Temporarily ignore all source map warnings
webpackConfig.ignoreWarnings = [/Failed to parse source map/];
return webpackConfig;
},
},
};