Skip to content

Commit

Permalink
fix: fix resource validation & move config
Browse files Browse the repository at this point in the history
  • Loading branch information
OliwiaGowor committed Sep 25, 2024
1 parent 881e48b commit 47bef30
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 43 deletions.
34 changes: 0 additions & 34 deletions config-overrides/index.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,6 @@
// this overrides configs of webpack and jest. See react-app-rewired documentation for details

const path = require('path');
const webpack = require('webpack');
const CopyPlugin = require('copy-webpack-plugin');

module.exports = {
webpack: function override(config, env) {
config.resolve.alias = {
// register aliases also in jsconfig.json
shared: path.resolve(__dirname, 'src/shared'),
...config.resolve.alias,
};

config.resolve.extensions = [...config.resolve.extensions, '.ts', '.tsx'];
config.plugins = [
...config.plugins,
new webpack.DefinePlugin({
'process.env.IS_DOCKER': env.IS_DOCKER,
}),
new CopyPlugin({
patterns: [
{
from: 'resources/base/resource-validation/rule-sets/**/*.yaml',
to: 'resource-validation/rule-set.yaml',
transformAll(assets) {
return assets.reduce((accumulator, asset) => {
return `${accumulator}---\n${asset.data}\n`;
}, '');
},
},
],
}),
];

return config;
},
jest: function(config) {
config.moduleNameMapper = {
'^shared/?(.*)': '<rootDir>/src/shared/$1',
Expand Down
64 changes: 59 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@
"babel-polyfill": "^6.26.0",
"babel-preset-vite": "^1.1.3",
"concurrently": "^7.6.0",
"copy-webpack-plugin": "^11.0.0",
"enzyme": "^3.10.0",
"enzyme-to-json": "^3.4.0",
"husky": "^2.4.1",
Expand All @@ -134,6 +133,7 @@
"typescript": "^4.8.4",
"uuid": "^9.0.0",
"vite": "^5.4.3",
"vite-plugin-static-copy": "^1.0.6",
"vite-plugin-svgr": "^4.2.0",
"vite-tsconfig-paths": "^5.0.1"
},
Expand Down
2 changes: 1 addition & 1 deletion src/state/validationSchemasAtom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type ValidationPolicy = {

const fetchBaseValidationConfig = async (): Promise<ValidationConfig[]> => {
try {
const response = await fetch(`/examples/resource-validation/rule-set.yaml`);
const response = await fetch(`/resource-validation/rule-set.yaml`);
const text = await response.text();
return jsyaml.loadAll(text) as ValidationConfig[];
} catch (error) {
Expand Down
26 changes: 24 additions & 2 deletions vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { defineConfig, transformWithEsbuild } from 'vite';
import viteTsconfigPaths from 'vite-tsconfig-paths';
import svgr from 'vite-plugin-svgr';
import react from '@vitejs/plugin-react';
import { viteStaticCopy } from 'vite-plugin-static-copy';
import path from 'path';

// https://vitejs.dev/config/
export default defineConfig({
Expand Down Expand Up @@ -30,11 +32,22 @@ export default defineConfig({
svgr({
include: '**/*.svg?react',
}),
viteStaticCopy({
targets: [
{
src: 'resources/base/resource-validation/rule-sets/**/*.yaml',
dest: 'resource-validation',
rename: 'rule-set.yaml',
transform(content) {
return `---\n${content.toString()}\n`;
},
},
],
}),
],
worker: {
plugins: () => [viteTsconfigPaths()],
},

optimizeDeps: {
force: true,
esbuildOptions: {
Expand All @@ -44,7 +57,16 @@ export default defineConfig({
},
include: [
'@openapi-contrib/openapi-schema-to-json-schema',
'@stoplight/json-ref-resolver'
'@stoplight/json-ref-resolver',
'monaco-yaml/yaml.worker.js'
]
},
resolve: {
alias: {
shared: path.resolve(__dirname, 'src/shared'),
},
},
define: {
'process.env.IS_DOCKER': JSON.stringify(process.env.IS_DOCKER),
},
});

0 comments on commit 47bef30

Please sign in to comment.