From 4fb36375ec073d6b642a1e3b1461676a07cb218c Mon Sep 17 00:00:00 2001 From: Gearonix Date: Fri, 1 Sep 2023 23:19:57 +0300 Subject: [PATCH] chore(vite): moved vite configs --- apps/client/.config/vite/entry.ts | 2 +- apps/client/project.json | 2 +- apps/client/src/vite.config.ts | 35 ----------------- libs/config/src/vite/builders/build.ts | 2 +- libs/web/editor/.config/vite.ts | 22 +++++++++++ libs/web/editor/project.json | 3 +- libs/web/editor/src/index.ts | 1 + libs/web/editor/vite.config.ts | 53 -------------------------- libs/web/shared/.config/vite.ts | 20 ++++++++++ libs/web/shared/project.json | 3 +- libs/web/shared/vite.config.ts | 47 ----------------------- libs/web/ui/.config/vite.ts | 19 +++++++++ libs/web/ui/project.json | 3 +- libs/web/ui/vite.config.ts | 53 -------------------------- 14 files changed, 71 insertions(+), 194 deletions(-) delete mode 100644 apps/client/src/vite.config.ts create mode 100644 libs/web/editor/.config/vite.ts create mode 100644 libs/web/editor/src/index.ts delete mode 100644 libs/web/editor/vite.config.ts create mode 100644 libs/web/shared/.config/vite.ts delete mode 100644 libs/web/shared/vite.config.ts create mode 100644 libs/web/ui/.config/vite.ts delete mode 100644 libs/web/ui/vite.config.ts diff --git a/apps/client/.config/vite/entry.ts b/apps/client/.config/vite/entry.ts index c02a7fd4..ab8e8de2 100644 --- a/apps/client/.config/vite/entry.ts +++ b/apps/client/.config/vite/entry.ts @@ -1,5 +1,5 @@ // It is important to specify relative paths here. -import { createViteConfig } from '../../../libs/config/src/vite' +import { createViteConfig } from '../../../../libs/config/src/vite' import { resolve } from 'path' import { buildCustomPlugins } from './plugins' diff --git a/apps/client/project.json b/apps/client/project.json index 9799d914..0a89444b 100644 --- a/apps/client/project.json +++ b/apps/client/project.json @@ -20,7 +20,7 @@ "options": { "outputPath": "dist/apps/client", "skipTypeCheck": true, - "configFile": "apps/client/src/vite.config.ts" + "configFile": "apps/client/.config/vite/entry.ts" }, "configurations": { "development": { diff --git a/apps/client/src/vite.config.ts b/apps/client/src/vite.config.ts deleted file mode 100644 index a0621a1d..00000000 --- a/apps/client/src/vite.config.ts +++ /dev/null @@ -1,35 +0,0 @@ -import preact from '@preact/preset-vite' -import { createViteConfig } from '../../../libs/config/src/vite' -import { resolve } from 'path' -import { VitePWA } from 'vite-plugin-pwa' -import webfontDownload from 'vite-plugin-webfont-dl' - -export default createViteConfig({ - projectName: 'client', - projectType: 'application', - rootDir: resolve(__dirname, '..'), - layer: 'second', - external: [], - plugins: [ - webfontDownload([ - 'https://fonts.googleapis.com/css2?family=Poppins&display=swap' - ]), - preact(), - VitePWA({ - registerType: 'autoUpdate', - injectRegister: 'auto', - strategies: 'injectManifest', - srcDir: 'public', - filename: 'service-worker.js', - workbox: { - globPatterns: ['**/*.{js,css,html,ico,png,svg}'], - clientsClaim: true, - skipWaiting: true - }, - devOptions: { - enabled: false - }, - includeAssets: ['**/*'] - }) - ] -}) diff --git a/libs/config/src/vite/builders/build.ts b/libs/config/src/vite/builders/build.ts index ac6224c4..4c5075cf 100644 --- a/libs/config/src/vite/builders/build.ts +++ b/libs/config/src/vite/builders/build.ts @@ -8,7 +8,7 @@ export const defineBuildOptions = ( return { lib: { entry: 'src/index.ts', - name: 'client-shared', + name: options.projectName, fileName: 'index', formats: ['es', 'cjs'] }, diff --git a/libs/web/editor/.config/vite.ts b/libs/web/editor/.config/vite.ts new file mode 100644 index 00000000..094dcc6b --- /dev/null +++ b/libs/web/editor/.config/vite.ts @@ -0,0 +1,22 @@ +// It is important to specify relative paths here. +import { createViteConfig } from '../../../../libs/config/src/vite' + +import { resolve } from 'path' +import react from '@vitejs/plugin-react' +import dynamicImport from 'vite-plugin-dynamic-import' + +export default createViteConfig({ + projectName: 'editor', + projectType: 'library', + rootDir: resolve(__dirname, '..'), + layer: 'third', + external: [ + 'antd', + 'react-router-dom', + 'react-smooth-scrollbar' + ], + plugins: [ + react(), + dynamicImport() + ] +}) diff --git a/libs/web/editor/project.json b/libs/web/editor/project.json index 25f06546..b73efb7c 100644 --- a/libs/web/editor/project.json +++ b/libs/web/editor/project.json @@ -25,7 +25,8 @@ "defaultConfiguration": "production", "options": { "outputPath": "dist/libs/web/editor", - "skipTypeCheck": true + "skipTypeCheck": true, + "configFile": "libs/web/editor/.config/vite.ts" }, "configurations": { "development": { diff --git a/libs/web/editor/src/index.ts b/libs/web/editor/src/index.ts new file mode 100644 index 00000000..57a83383 --- /dev/null +++ b/libs/web/editor/src/index.ts @@ -0,0 +1 @@ +export * from './app' diff --git a/libs/web/editor/vite.config.ts b/libs/web/editor/vite.config.ts deleted file mode 100644 index c9adbcb4..00000000 --- a/libs/web/editor/vite.config.ts +++ /dev/null @@ -1,53 +0,0 @@ -// / -import * as path from 'path' -import { defineConfig } from 'vite' -import dts from 'vite-plugin-dts' -import dynamicImport from 'vite-plugin-dynamic-import' -import viteTsConfigPaths from 'vite-tsconfig-paths' - -import react from '@vitejs/plugin-react' - -export default defineConfig({ - cacheDir: '../../../node_modules/.vite/editor', - define: { - 'process.env': process.env - }, - plugins: [ - dts({ - entryRoot: 'src', - tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'), - skipDiagnostics: true - }), - react(), - viteTsConfigPaths({ - root: '../../../' - }), - dynamicImport() - ], - build: { - lib: { - entry: 'src/app/index.js', - name: 'editor', - fileName: 'index', - formats: ['es', 'cjs'] - }, - rollupOptions: { - external: [ - 'react', - 'react-dom', - 'react/jsx-runtime', - 'antd', - 'react-router-dom', - 'react-smooth-scrollbar' - ] - } - }, - test: { - globals: true, - cache: { - dir: '../../../node_modules/.vitest' - }, - environment: 'jsdom', - include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'] - } -}) diff --git a/libs/web/shared/.config/vite.ts b/libs/web/shared/.config/vite.ts new file mode 100644 index 00000000..17a3ff7b --- /dev/null +++ b/libs/web/shared/.config/vite.ts @@ -0,0 +1,20 @@ +// It is important to specify relative paths here. +import { createViteConfig } from '../../../../libs/config/src/vite' + +import { resolve } from 'path' +import react from '@vitejs/plugin-react' + +export default createViteConfig({ + projectName: 'web-shared', + projectType: 'library', + rootDir: resolve(__dirname, '..'), + layer: 'third', + external: [ + 'react-smooth-scrollbar', + 'antd', + 'react-router-dom', + ], + plugins: [ + react(), + ] +}) diff --git a/libs/web/shared/project.json b/libs/web/shared/project.json index ad6b3add..81c39cb6 100644 --- a/libs/web/shared/project.json +++ b/libs/web/shared/project.json @@ -25,7 +25,8 @@ "options": { "outputPath": "dist/libs/web/shared", "skipTypeCheck": true, - "fix": true + "fix": true, + "configFile": "libs/web/shared/.config/vite.ts" }, "configurations": { "development": { diff --git a/libs/web/shared/vite.config.ts b/libs/web/shared/vite.config.ts deleted file mode 100644 index 2c7baee5..00000000 --- a/libs/web/shared/vite.config.ts +++ /dev/null @@ -1,47 +0,0 @@ -// / -import * as path from 'path' -import { defineConfig } from 'vite' -import dts from 'vite-plugin-dts' -import viteTsConfigPaths from 'vite-tsconfig-paths' - -import react from '@vitejs/plugin-react' - -export default defineConfig({ - cacheDir: '../../../node_modules/.vite/client-shared', - plugins: [ - dts({ - entryRoot: 'src', - tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'), - skipDiagnostics: true - }), - react(), - viteTsConfigPaths({ - root: '../../../' - }) - ], - build: { - lib: { - entry: 'src/index.ts', - name: 'client-shared', - fileName: 'index', - formats: ['es', 'cjs'] - }, - rollupOptions: { - external: [ - 'react', - 'react-dom', - 'react/jsx-runtime', - 'react-smooth-scrollbar' - ] - } - }, - - test: { - globals: true, - cache: { - dir: '../../../node_modules/.vitest' - }, - environment: 'jsdom', - include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'] - } -}) diff --git a/libs/web/ui/.config/vite.ts b/libs/web/ui/.config/vite.ts new file mode 100644 index 00000000..ee722012 --- /dev/null +++ b/libs/web/ui/.config/vite.ts @@ -0,0 +1,19 @@ +// It is important to specify relative paths here. +import { createViteConfig } from '../../../../libs/config/src/vite' + +import { resolve } from 'path' +import react from '@vitejs/plugin-react' + +export default createViteConfig({ + projectName: 'shared', + projectType: 'library', + rootDir: resolve(__dirname, '..'), + layer: 'third', + external: [ + 'react-smooth-scrollbar', + 'antd' + ], + plugins: [ + react(), + ] +}) diff --git a/libs/web/ui/project.json b/libs/web/ui/project.json index 396b4217..bad818cb 100644 --- a/libs/web/ui/project.json +++ b/libs/web/ui/project.json @@ -82,7 +82,8 @@ "defaultConfiguration": "production", "options": { "outputPath": "dist/libs/web/ui", - "skipTypeCheck": true + "skipTypeCheck": true, + "configFile": "libs/web/ui/.config/vite.ts" }, "configurations": { "development": { diff --git a/libs/web/ui/vite.config.ts b/libs/web/ui/vite.config.ts deleted file mode 100644 index 9307c7ad..00000000 --- a/libs/web/ui/vite.config.ts +++ /dev/null @@ -1,53 +0,0 @@ -/// -import { defineConfig } from 'vite' -import react from '@vitejs/plugin-react' -import viteTsConfigPaths from 'vite-tsconfig-paths' -import dts from 'vite-plugin-dts' -import * as path from 'path' -// import './.storybook/test-runner.config' - -export default defineConfig({ - cacheDir: '../../../node_modules/.vite/ui', - - plugins: [ - dts({ - entryRoot: 'src', - tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'), - skipDiagnostics: true - }), - react(), - viteTsConfigPaths({ - root: '../../../' - }) - ], - build: { - lib: { - entry: 'src/index.ts', - name: 'ui', - fileName: 'index', - formats: ['es', 'cjs'] - }, - rollupOptions: { - external: [ - 'react', - 'react-dom', - 'react/jsx-runtime', - 'antd', - 'react-router-dom', - 'react-smooth-scrollbar', - 'cg-client-shared', - 'cg-config', - 'sb-cache' - ] - } - }, - - test: { - globals: true, - cache: { - dir: '../../../node_modules/.vitest' - }, - environment: 'jsdom', - include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'] - } -})