From b0d46987a4af4ee3447dbd4eb38e566ee4068c22 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 18 Sep 2023 18:53:25 -0500 Subject: [PATCH 1/4] tailwind: use the correct path for index.html --- tailwind.config.cjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tailwind.config.cjs b/tailwind.config.cjs index 57ff65f3c8..36b7a1efcd 100644 --- a/tailwind.config.cjs +++ b/tailwind.config.cjs @@ -2,7 +2,7 @@ const { parseColorMatrix } = require('./tailwind/colors.cjs'); /** @type {import('tailwindcss').Config} */ module.exports = { - content: ['./src/**/*.{html,js,ts,tsx}', './custom/instance/**/*.html', './src/index.html'], + content: ['./src/**/*.{html,js,ts,tsx}', './custom/instance/**/*.html', './index.html'], darkMode: 'class', theme: { screens: { From 199d5d9f378359d031f0e88eea9a3dfaef352990 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 18 Sep 2023 18:57:34 -0500 Subject: [PATCH 2/4] Remove FE_BUILD_DIR build config --- docs/development/build-config.md | 12 +----------- src/build-config-compiletime.ts | 6 ------ src/build-config.ts | 2 -- 3 files changed, 1 insertion(+), 19 deletions(-) diff --git a/docs/development/build-config.md b/docs/development/build-config.md index ceae106312..b4236d39da 100644 --- a/docs/development/build-config.md +++ b/docs/development/build-config.md @@ -118,7 +118,7 @@ When compiling Soapbox, environment variables may be passed to change the build For example: ```sh -NODE_ENV="production" FE_BUILD_DIR="public" FE_SUBDIRECTORY="/soapbox" yarn build +NODE_ENV="production" FE_SUBDIRECTORY="/soapbox" yarn build ``` ### `NODE_ENV` @@ -147,16 +147,6 @@ Options: Default: `""` -### `FE_BUILD_DIR` - -The folder to put build files in. This is mostly useful for CI tasks like GitLab Pages. - -Options: - -- Any directory name, eg `"public"` - -Default: `"dist"` - ### `FE_SUBDIRECTORY` Subdirectory to host Soapbox out of. diff --git a/src/build-config-compiletime.ts b/src/build-config-compiletime.ts index 6f9cb2aba4..15915cbdbb 100644 --- a/src/build-config-compiletime.ts +++ b/src/build-config-compiletime.ts @@ -12,7 +12,6 @@ const { NODE_ENV, BACKEND_URL, FE_SUBDIRECTORY, - FE_BUILD_DIR, FE_INSTANCE_SOURCE_DIR, SENTRY_DSN, } = process.env; @@ -29,16 +28,11 @@ const sanitizeBasename = (path: string | undefined = ''): string => { return `/${trim(path, '/')}`; }; -const sanitizePath = (path: string | undefined = ''): string => { - return trim(path, '/'); -}; - export default () => ({ data: { NODE_ENV: NODE_ENV || 'development', BACKEND_URL: sanitizeURL(BACKEND_URL), FE_SUBDIRECTORY: sanitizeBasename(FE_SUBDIRECTORY), - FE_BUILD_DIR: sanitizePath(FE_BUILD_DIR) || 'dist', FE_INSTANCE_SOURCE_DIR: FE_INSTANCE_SOURCE_DIR || 'instance', SENTRY_DSN, }, diff --git a/src/build-config.ts b/src/build-config.ts index e3e5436bf7..38515cdd30 100644 --- a/src/build-config.ts +++ b/src/build-config.ts @@ -3,7 +3,6 @@ const { NODE_ENV, BACKEND_URL, FE_SUBDIRECTORY, - FE_BUILD_DIR, FE_INSTANCE_SOURCE_DIR, SENTRY_DSN, } = import.meta.compileTime('./build-config-compiletime.ts'); @@ -12,7 +11,6 @@ export { NODE_ENV, BACKEND_URL, FE_SUBDIRECTORY, - FE_BUILD_DIR, FE_INSTANCE_SOURCE_DIR, SENTRY_DSN, }; \ No newline at end of file From 95b7c62f679bd072f59df2716eadaeecc7323426 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 18 Sep 2023 19:14:23 -0500 Subject: [PATCH 3/4] Support snippets.html again --- index.html | 1 + vite.config.ts | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 280ab913ff..25e84494af 100644 --- a/index.html +++ b/index.html @@ -8,6 +8,7 @@ + <%- snippets %>
diff --git a/vite.config.ts b/vite.config.ts index 263f6a20bd..8141f5b8b8 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,4 +1,5 @@ /// +import fs from 'node:fs'; import { fileURLToPath, URL } from 'node:url'; import react from '@vitejs/plugin-react'; @@ -36,6 +37,11 @@ export default defineConfig({ collapseWhitespace: true, removeComments: false, }, + inject: { + data: { + snippets: readFileContents('custom/snippets.html'), + }, + }, }), react({ // Use React plugin in all *.jsx and *.tsx files @@ -88,4 +94,13 @@ export default defineConfig({ environment: 'jsdom', setupFiles: 'src/jest/test-setup.ts', }, -}); \ No newline at end of file +}); + +/** Return file as string, or return empty string if the file isn't found. */ +function readFileContents(path: string) { + try { + return fs.readFileSync(path, 'utf8'); + } catch { + return ''; + } +} From aad07daa33e001a8d653129be0d7fdd4777f0894 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 18 Sep 2023 19:20:08 -0500 Subject: [PATCH 4/4] vite: copy in custom instance dir --- vite.config.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vite.config.ts b/vite.config.ts index 8141f5b8b8..ca86db12d3 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -76,6 +76,9 @@ export default defineConfig({ }, { src: './src/instance', dest: '.', + }, { + src: './custom/instance', + dest: '.', }], }), visualizer({