Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[front] fix vite & delte useless jest files #453

Merged
merged 4 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions openex-front/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!doctype html>
<html lang="en">
<head>
<script>window.BASE_PATH = "%BASE_PATH%"</script>
<title>%APP_TITLE%</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="dеѕсrірtіоn" content="%APP_DESCRIPTION%">
<!-- <link id="favicon" rel="shortcut icon" href="%APP_FAVICON%">
<link id="manifest" rel="manifest" href="%APP_MANIFEST%"> -->
RomuDeuxfois marked this conversation as resolved.
Show resolved Hide resolved
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
36 changes: 0 additions & 36 deletions openex-front/jest.config.cjs

This file was deleted.

11 changes: 0 additions & 11 deletions openex-front/jest/jest.file.transform.cjs

This file was deleted.

8 changes: 0 additions & 8 deletions openex-front/jest/jest.setup.js

This file was deleted.

5 changes: 5 additions & 0 deletions openex-front/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,10 @@
},
"include": [
"src", "index.d.ts"
],
"references": [
{
"path": "./tsconfig.node.json"
}
]
}
100 changes: 51 additions & 49 deletions openex-front/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,58 @@
import { defineConfig, transformWithEsbuild } from 'vite';
import { createLogger, defineConfig, transformWithEsbuild } from 'vite';
import react from '@vitejs/plugin-react-swc';

const logger = createLogger()
const loggerError = logger.error

logger.error = (msg, options) => {
// Ignore jsx syntax error as it taken into account in a custom plugin
if (msg.includes('The JSX syntax extension is not currently enabled')) return
loggerError(msg, options)
}

const basePath = "";

const backProxy = {
target: 'http://localhost:8080',
changeOrigin: true,
ws: true,
};

// https://vitejs.dev/config/
export default defineConfig({
build: {
target: ['chrome58'],
},

resolve: {
extensions: ['.js', '.tsx', '.ts', '.jsx', '.json'],
},

optimizeDeps: {
include: [
'ckeditor5-custom-build/build/ckeditor',
],
},

customLogger: logger,

plugins: [
{
name: 'html-transform',
enforce: "pre",
apply: 'serve',
transformIndexHtml(html) {
return html.replace(/%BASE_PATH%/g, basePath)
.replace(/%APP_TITLE%/g, "OpenEx Dev")
.replace(/%APP_DESCRIPTION%/g, "OpenEx Development platform")
.replace(/%APP_FAVICON%/g, `${basePath}/static/ext/favicon.png`)
.replace(/%APP_MANIFEST%/g, `${basePath}/static/ext/manifest.json`)
}
},
{
name: 'treat-js-files-as-jsx',
async transform(code, id) {
if (!id.match(/src\/.*\.js$/)) return null;

// Use the exposed transform from vite, instead of directly
// transforming with esbuild
return transformWithEsbuild(code, id, {
Expand All @@ -17,31 +61,9 @@ export default defineConfig({
});
},
},
{
name: 'asset-base-url',
enforce: 'post',
transform: (code) => {
code = code.replace(/(?<!local)(\/src|~?@|\/@fs\/@)\/(.*?)\.(svg|png)/g, 'src/$2.$3');
return {
code,
map: null,
};
},
},
react(),
],

publicDir: 'builder/public',
resolve: {
extensions: ['.js', '.tsx', '.ts', '.jsx', '.json'],
},

optimizeDeps: {
include: [
'ckeditor5-custom-build/build/ckeditor',
],
},

server: {
port: 3000,
warmup: {
Expand All @@ -54,31 +76,11 @@ export default defineConfig({
],
},
proxy: {
'/api': {
target: 'http://localhost:8080',
changeOrigin: true,
ws: true,
},
'/login': {
target: 'http://localhost:8080',
changeOrigin: true,
ws: true,
},
'/logout': {
target: 'http://localhost:8080',
changeOrigin: true,
ws: true,
},
'/oauth2': {
target: 'http://localhost:8080',
changeOrigin: true,
ws: true,
},
'/saml2': {
target: 'http://localhost:8080',
changeOrigin: true,
ws: true,
},
'/api': backProxy,
'/login': backProxy,
'/logout': backProxy,
'/oauth2': backProxy,
'/saml2': backProxy,
},
},
});
Loading