diff --git a/packages/twenty-front/project.json b/packages/twenty-front/project.json index 636fd29af6a6..4dcb7f444a00 100644 --- a/packages/twenty-front/project.json +++ b/packages/twenty-front/project.json @@ -10,6 +10,12 @@ "outputPath": "{projectRoot}/build" } }, + "serve": { + "executor": "nx:run-commands", + "options": { + "command": "npx serve -s {projectRoot}/build" + } + }, "start": { "executor": "@nx/vite:dev-server", "options": { diff --git a/packages/twenty-front/src/modules/ui/display/status/components/__stories__/Status.stories.tsx b/packages/twenty-front/src/modules/ui/display/status/components/__stories__/Status.stories.tsx index 7db5637d0497..cd480d45aae2 100644 --- a/packages/twenty-front/src/modules/ui/display/status/components/__stories__/Status.stories.tsx +++ b/packages/twenty-front/src/modules/ui/display/status/components/__stories__/Status.stories.tsx @@ -15,6 +15,7 @@ const meta: Meta = { component: Status, args: { text: 'Urgent', + weight: 'medium', }, }; diff --git a/packages/twenty-front/tsconfig.build.json b/packages/twenty-front/tsconfig.build.json new file mode 100644 index 000000000000..7a17e21fdea8 --- /dev/null +++ b/packages/twenty-front/tsconfig.build.json @@ -0,0 +1,22 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "types": ["node"] + }, + "exclude": [ + "**/__mocks__/**/*", + "**/*.spec.ts", + "**/*.spec.tsx", + "**/*.stories.ts", + "**/*.stories.tsx", + "**/*.test.ts", + "**/*.test.tsx" + ], + "include": [ + "src/**/*.js", + "src/**/*.jsx", + "src/**/*.d.ts", + "src/**/*.ts", + "src/**/*.tsx" + ] +} diff --git a/packages/twenty-front/tsconfig.app.json b/packages/twenty-front/tsconfig.dev.json similarity index 84% rename from packages/twenty-front/tsconfig.app.json rename to packages/twenty-front/tsconfig.dev.json index 9e43a624310d..f90dcae862bb 100644 --- a/packages/twenty-front/tsconfig.app.json +++ b/packages/twenty-front/tsconfig.dev.json @@ -3,7 +3,6 @@ "compilerOptions": { "types": ["node"] }, - "exclude": ["**/__mocks__/**/*"], "include": [ "src/**/*.js", "src/**/*.jsx", diff --git a/packages/twenty-front/tsconfig.json b/packages/twenty-front/tsconfig.json index 1c9a73c46be1..f6c268d9c2fd 100644 --- a/packages/twenty-front/tsconfig.json +++ b/packages/twenty-front/tsconfig.json @@ -32,7 +32,10 @@ "include": [], "references": [ { - "path": "./tsconfig.app.json" + "path": "./tsconfig.dev.json" + }, + { + "path": "./tsconfig.build.json" }, { "path": "./tsconfig.spec.json" diff --git a/packages/twenty-front/vite.config.ts b/packages/twenty-front/vite.config.ts index 924f9c9d7ee0..682b6466ab40 100644 --- a/packages/twenty-front/vite.config.ts +++ b/packages/twenty-front/vite.config.ts @@ -19,9 +19,13 @@ export default defineConfig(({ command, mode }) => { const isBuildCommand = command === 'build'; + const tsConfigPath = isBuildCommand + ? path.resolve(__dirname, './tsconfig.build.json') + : path.resolve(__dirname, './tsconfig.dev.json'); + const checkers: Checkers = { typescript: { - tsconfigPath: path.resolve(__dirname, './tsconfig.app.json'), + tsconfigPath: tsConfigPath, }, overlay: false, }; diff --git a/packages/twenty-ui/src/utilities/config/index.ts b/packages/twenty-ui/src/utilities/config/index.ts index 4525e814d61b..5038c501089a 100644 --- a/packages/twenty-ui/src/utilities/config/index.ts +++ b/packages/twenty-ui/src/utilities/config/index.ts @@ -25,6 +25,4 @@ const getDefaultUrl = () => { }; export const REACT_APP_SERVER_BASE_URL = - window._env_?.REACT_APP_SERVER_BASE_URL || - process.env.REACT_APP_SERVER_BASE_URL || - getDefaultUrl(); + window._env_?.REACT_APP_SERVER_BASE_URL || getDefaultUrl(); diff --git a/packages/twenty-ui/tsconfig.lib.json b/packages/twenty-ui/tsconfig.build.json similarity index 100% rename from packages/twenty-ui/tsconfig.lib.json rename to packages/twenty-ui/tsconfig.build.json diff --git a/packages/twenty-ui/tsconfig.dev.json b/packages/twenty-ui/tsconfig.dev.json new file mode 100644 index 000000000000..a6281404512a --- /dev/null +++ b/packages/twenty-ui/tsconfig.dev.json @@ -0,0 +1,12 @@ +{ + "extends": "./tsconfig.json", + "exclude": [ + "**/*.spec.ts", + "**/*.spec.tsx", + "**/*.stories.ts", + "**/*.stories.tsx", + "**/*.test.ts", + "**/*.test.tsx" + ], + "include": ["src/**/*.d.ts", "src/**/*.ts", "src/**/*.tsx"] +} diff --git a/packages/twenty-ui/tsconfig.json b/packages/twenty-ui/tsconfig.json index c7c587845c85..cb70a38df1ed 100644 --- a/packages/twenty-ui/tsconfig.json +++ b/packages/twenty-ui/tsconfig.json @@ -17,7 +17,10 @@ "include": [], "references": [ { - "path": "./tsconfig.lib.json" + "path": "./tsconfig.build.json" + }, + { + "path": "./tsconfig.dev.json" }, { "path": "./tsconfig.spec.json" diff --git a/packages/twenty-ui/vite.config.ts b/packages/twenty-ui/vite.config.ts index 3692ff065325..8bad93448bd2 100644 --- a/packages/twenty-ui/vite.config.ts +++ b/packages/twenty-ui/vite.config.ts @@ -4,64 +4,78 @@ import wyw from '@wyw-in-js/vite'; import * as path from 'path'; import { defineConfig } from 'vite'; import checker from 'vite-plugin-checker'; -import dts from 'vite-plugin-dts'; +import dts, { PluginOptions } from 'vite-plugin-dts'; import svgr from 'vite-plugin-svgr'; import tsconfigPaths from 'vite-tsconfig-paths'; +import { UserPluginConfig } from 'vite-plugin-checker/dist/esm/types'; + // eslint-disable-next-line @nx/enforce-module-boundaries, import/no-relative-packages import packageJson from '../../package.json'; -export default defineConfig({ - root: __dirname, - cacheDir: '../../node_modules/.vite/packages/twenty-ui', +export default defineConfig(({ command, mode }) => { + const isBuildCommand = command === 'build'; - plugins: [ - react({ jsxImportSource: '@emotion/react' }), - tsconfigPaths(), - svgr(), - dts({ - entryRoot: 'src', - tsconfigPath: path.join(__dirname, 'tsconfig.lib.json'), - }), - checker({ - typescript: { - tsconfigPath: path.join(__dirname, 'tsconfig.lib.json'), - }, - }), - wyw({ - include: [ - '**/OverflowingTextWithTooltip.tsx', - '**/Chip.tsx', - '**/Tag.tsx', - '**/Avatar.tsx', - '**/AvatarChip.tsx', - ], - babelOptions: { - presets: ['@babel/preset-typescript', '@babel/preset-react'], - }, - }), - ], + const tsConfigPath = isBuildCommand + ? path.resolve(__dirname, './tsconfig.build.json') + : path.resolve(__dirname, './tsconfig.dev.json'); - // Configuration for building your library. - // See: https://vitejs.dev/guide/build.html#library-mode - build: { - outDir: './dist', - reportCompressedSize: true, - commonjsOptions: { - transformMixedEsModules: true, + const checkersConfig: UserPluginConfig = { + typescript: { + tsconfigPath: tsConfigPath, }, - lib: { - // Could also be a dictionary or array of multiple entry points. - entry: 'src/index.ts', - name: 'twenty-ui', - fileName: 'index', - // Change this to the formats you want to support. - // Don't forget to update your package.json as well. - formats: ['es', 'cjs'], - }, - rollupOptions: { - // External packages that should not be bundled into your library. - external: Object.keys(packageJson.dependencies || {}), + }; + + const dtsConfig: PluginOptions = { + entryRoot: 'src', + tsconfigPath: tsConfigPath, + }; + + return { + root: __dirname, + cacheDir: '../../node_modules/.vite/packages/twenty-ui', + + plugins: [ + react({ jsxImportSource: '@emotion/react' }), + tsconfigPaths(), + svgr(), + dts(dtsConfig), + checker(checkersConfig), + wyw({ + include: [ + '**/OverflowingTextWithTooltip.tsx', + '**/Chip.tsx', + '**/Tag.tsx', + '**/Avatar.tsx', + '**/AvatarChip.tsx', + ], + babelOptions: { + presets: ['@babel/preset-typescript', '@babel/preset-react'], + }, + }), + ], + + // Configuration for building your library. + // See: https://vitejs.dev/guide/build.html#library-mode + build: { + outDir: './dist', + reportCompressedSize: true, + commonjsOptions: { + transformMixedEsModules: true, + }, + lib: { + // Could also be a dictionary or array of multiple entry points. + entry: 'src/index.ts', + name: 'twenty-ui', + fileName: 'index', + // Change this to the formats you want to support. + // Don't forget to update your package.json as well. + formats: ['es', 'cjs'], + }, + rollupOptions: { + // External packages that should not be bundled into your library. + external: Object.keys(packageJson.dependencies || {}), + }, }, - }, + }; });