The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
import react from '@vitejs/plugin-react-swc';
import { Features } from 'lightningcss';
import * as path from 'path';
import { defineConfig } from 'vite';
import svgr from 'vite-plugin-svgr';
import { wrapInTwentyUiCascadeLayer } from './build-tools/wrapInTwentyUiCascadeLayer';
import packageJson from './package.json';
// bundled so consumers only parse the icons twenty-ui uses, not the 6,000-module barrel
const BUNDLED_DEPS = ['@tabler/icons-react'];
const depNames = Object.keys({
...(packageJson.dependencies || {}),
...(packageJson.peerDependencies || {}),
}).filter((dep) => !BUNDLED_DEPS.includes(dep));
const isExternal = (id: string): boolean =>
depNames.some((dep) => id === dep || id.startsWith(dep + '/'));
const entries = Object.keys(packageJson.exports)
.filter((subpath) => !subpath.endsWith('.css'))
.map((subpath) =>
subpath === '.' ? 'src/individual-entry.ts' : `src/${subpath}/index.ts`,
);
export default defineConfig(() => {
return {
resolve: {
tsconfigPaths: true,
alias: {
'@ui/': path.resolve(__dirname, 'src') + '/',
'@assets/': path.resolve(__dirname, 'src/assets') + '/',
'@styles/': path.resolve(__dirname, 'src/styles') + '/',
},
},
css: {
modules: {
localsConvention: 'camelCaseOnly',
},
postcss: {
plugins: [
wrapInTwentyUiCascadeLayer({
sourceDirectory: path.resolve(__dirname, 'src'),
}),
],
},
lightningcss: {
exclude: Features.DirSelector,
},
preprocessorOptions: {
scss: {
api: 'modern-compiler',
loadPaths: [path.resolve(__dirname, 'src/styles')],
additionalData: [
`@use 'abstracts/functions' as *;`,
`@use 'abstracts/mixins' as *;`,
`@use 'abstracts/breakpoints' as *;`,
'',
].join('\n'),
},
},
},
root: __dirname,
cacheDir: '../../node_modules/.vite/packages/twenty-ui-individual',
assetsInclude: ['src/**/*.svg'],
plugins: [react(), svgr()],
build: {
cssCodeSplit: false,
minify: 'esbuild',
sourcemap: true,
outDir: './dist/individual',
emptyOutDir: true,
commonjsOptions: {
transformMixedEsModules: true,
interopDefault: true,
defaultIsModuleExports: true,
requireReturnsDefault: 'auto',
},
lib: {
entry: entries,
formats: ['es'],
},
rollupOptions: {
external: isExternal,
output: {
preserveModules: true,
preserveModulesRoot: 'src',
entryFileNames: '[name].js',
},
},
},
logLevel: 'warn',
};
});