-
Notifications
You must be signed in to change notification settings - Fork 0
/
craco.config.js
37 lines (32 loc) · 1.32 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
const chokidar = require('chokidar');
const { convertCsvFile } = require('./src/strings/export');
const fs = require('fs');
const { whenDev } = require('@craco/craco');
module.exports = {
devServer: (devServerConfig, { paths }) => ({
...devServerConfig,
// https://github.com/facebook/create-react-app/issues/11860#issuecomment-1140417343
onAfterSetupMiddleware: undefined,
onBeforeSetupMiddleware: undefined,
setupMiddlewares: (middlewares, devServer) => {
// Support hot reloading of edits to strings CSV files by converting them to JS when they
// change; the JS edits will be picked up by Webpack. The "add" event is fired when Chokidar
// first discovers each file, which will cause JS to be generated as part of server
// initialization.
const convert = (path) => convertCsvFile(path, 'src/strings');
chokidar.watch('src/strings/csv/*.csv').on('add', convert).on('change', convert);
if (fs.existsSync(paths.proxySetup)) {
require(paths.proxySetup)(devServer.app);
}
return middlewares;
},
}),
webpack: {
snapshot: {
...whenDev(() => ({
// Watch web-components, but not other modules, for changes.
managedPaths: [/^(.+?[\\/]node_modules[\\/](?!(@terraware[\\/]web-components))(@.+?[\\/])?.+?)[\\/]/],
})),
},
},
};