Merge branch 'snippets' into 'main'
Support snippets.html again See merge request soapbox-pub/soapbox!2706
This commit is contained in:
commit
025552d57f
6 changed files with 22 additions and 21 deletions
|
@ -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.
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
<link href="/manifest.json" rel="manifest">
|
||||
<!--server-generated-meta-->
|
||||
<script type="module" src="./src/main.tsx"></script>
|
||||
<%- snippets %>
|
||||
</head>
|
||||
<body class="theme-mode-light no-reduce-motion">
|
||||
<div id="soapbox" class="h-full">
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
|
|
|
@ -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,
|
||||
};
|
|
@ -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: {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/// <reference types="vitest" />
|
||||
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
|
||||
|
@ -70,6 +76,9 @@ export default defineConfig({
|
|||
}, {
|
||||
src: './src/instance',
|
||||
dest: '.',
|
||||
}, {
|
||||
src: './custom/instance',
|
||||
dest: '.',
|
||||
}],
|
||||
}),
|
||||
visualizer({
|
||||
|
@ -88,4 +97,13 @@ export default defineConfig({
|
|||
environment: 'jsdom',
|
||||
setupFiles: 'src/jest/test-setup.ts',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
/** 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 '';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue