2022-11-10 11:19:19 +08:00
|
|
|
const {
|
|
|
|
addWebpackModuleRule,
|
2023-04-18 17:38:08 +08:00
|
|
|
addWebpackAlias,
|
2022-11-10 11:19:19 +08:00
|
|
|
} = require("customize-cra");
|
|
|
|
|
|
|
|
const path = require("path");
|
|
|
|
const i18nPath = path.resolve(__dirname, "../i18n");
|
2022-09-27 17:59:05 +08:00
|
|
|
|
|
|
|
module.exports = {
|
2022-11-10 11:19:19 +08:00
|
|
|
webpack: function(config, env) {
|
|
|
|
addWebpackAlias({
|
2022-11-14 10:42:45 +08:00
|
|
|
"@": path.resolve(__dirname, "src"),
|
2022-11-10 11:19:19 +08:00
|
|
|
"@i18n": i18nPath
|
|
|
|
})(config);
|
2022-11-08 17:42:48 +08:00
|
|
|
|
2022-11-10 11:19:19 +08:00
|
|
|
addWebpackModuleRule({
|
|
|
|
test: /\.ya?ml$/,
|
|
|
|
use: "yaml-loader"
|
|
|
|
})(config);
|
2022-11-08 17:42:48 +08:00
|
|
|
|
2022-11-10 11:19:19 +08:00
|
|
|
// add i18n dir to ModuleScopePlugin allowedPaths
|
|
|
|
const moduleScopePlugin = config.resolve.plugins.find(_ => _.constructor.name === "ModuleScopePlugin");
|
|
|
|
if (moduleScopePlugin) {
|
|
|
|
moduleScopePlugin.allowedPaths.push(i18nPath);
|
|
|
|
}
|
2022-09-27 17:59:05 +08:00
|
|
|
|
|
|
|
return config;
|
|
|
|
},
|
2022-11-10 11:19:19 +08:00
|
|
|
devServer: function(configFunction) {
|
|
|
|
return function(proxy, allowedHost) {
|
2022-09-27 17:59:05 +08:00
|
|
|
const config = configFunction(proxy, allowedHost);
|
2022-12-21 10:11:44 +08:00
|
|
|
config.proxy = [
|
|
|
|
{
|
|
|
|
context: ['/answer', '/installation'],
|
2022-11-10 16:37:03 +08:00
|
|
|
target: process.env.REACT_APP_API_URL,
|
2022-11-03 17:44:59 +08:00
|
|
|
changeOrigin: true,
|
|
|
|
secure: false,
|
|
|
|
},
|
2022-12-21 10:11:44 +08:00
|
|
|
{
|
|
|
|
context: ['/custom.css'],
|
2022-11-10 16:37:03 +08:00
|
|
|
target: process.env.REACT_APP_API_URL,
|
2022-12-21 10:11:44 +08:00
|
|
|
}
|
|
|
|
];
|
2022-09-27 17:59:05 +08:00
|
|
|
return config;
|
|
|
|
};
|
2022-11-10 11:19:19 +08:00
|
|
|
}
|
2022-09-27 17:59:05 +08:00
|
|
|
};
|