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:
|
For example:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
NODE_ENV="production" FE_BUILD_DIR="public" FE_SUBDIRECTORY="/soapbox" yarn build
|
NODE_ENV="production" FE_SUBDIRECTORY="/soapbox" yarn build
|
||||||
```
|
```
|
||||||
|
|
||||||
### `NODE_ENV`
|
### `NODE_ENV`
|
||||||
|
@ -147,16 +147,6 @@ Options:
|
||||||
|
|
||||||
Default: `""`
|
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`
|
### `FE_SUBDIRECTORY`
|
||||||
|
|
||||||
Subdirectory to host Soapbox out of.
|
Subdirectory to host Soapbox out of.
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
<link href="/manifest.json" rel="manifest">
|
<link href="/manifest.json" rel="manifest">
|
||||||
<!--server-generated-meta-->
|
<!--server-generated-meta-->
|
||||||
<script type="module" src="./src/main.tsx"></script>
|
<script type="module" src="./src/main.tsx"></script>
|
||||||
|
<%- snippets %>
|
||||||
</head>
|
</head>
|
||||||
<body class="theme-mode-light no-reduce-motion">
|
<body class="theme-mode-light no-reduce-motion">
|
||||||
<div id="soapbox" class="h-full">
|
<div id="soapbox" class="h-full">
|
||||||
|
|
|
@ -12,7 +12,6 @@ const {
|
||||||
NODE_ENV,
|
NODE_ENV,
|
||||||
BACKEND_URL,
|
BACKEND_URL,
|
||||||
FE_SUBDIRECTORY,
|
FE_SUBDIRECTORY,
|
||||||
FE_BUILD_DIR,
|
|
||||||
FE_INSTANCE_SOURCE_DIR,
|
FE_INSTANCE_SOURCE_DIR,
|
||||||
SENTRY_DSN,
|
SENTRY_DSN,
|
||||||
} = process.env;
|
} = process.env;
|
||||||
|
@ -29,16 +28,11 @@ const sanitizeBasename = (path: string | undefined = ''): string => {
|
||||||
return `/${trim(path, '/')}`;
|
return `/${trim(path, '/')}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const sanitizePath = (path: string | undefined = ''): string => {
|
|
||||||
return trim(path, '/');
|
|
||||||
};
|
|
||||||
|
|
||||||
export default () => ({
|
export default () => ({
|
||||||
data: {
|
data: {
|
||||||
NODE_ENV: NODE_ENV || 'development',
|
NODE_ENV: NODE_ENV || 'development',
|
||||||
BACKEND_URL: sanitizeURL(BACKEND_URL),
|
BACKEND_URL: sanitizeURL(BACKEND_URL),
|
||||||
FE_SUBDIRECTORY: sanitizeBasename(FE_SUBDIRECTORY),
|
FE_SUBDIRECTORY: sanitizeBasename(FE_SUBDIRECTORY),
|
||||||
FE_BUILD_DIR: sanitizePath(FE_BUILD_DIR) || 'dist',
|
|
||||||
FE_INSTANCE_SOURCE_DIR: FE_INSTANCE_SOURCE_DIR || 'instance',
|
FE_INSTANCE_SOURCE_DIR: FE_INSTANCE_SOURCE_DIR || 'instance',
|
||||||
SENTRY_DSN,
|
SENTRY_DSN,
|
||||||
},
|
},
|
||||||
|
|
|
@ -3,7 +3,6 @@ const {
|
||||||
NODE_ENV,
|
NODE_ENV,
|
||||||
BACKEND_URL,
|
BACKEND_URL,
|
||||||
FE_SUBDIRECTORY,
|
FE_SUBDIRECTORY,
|
||||||
FE_BUILD_DIR,
|
|
||||||
FE_INSTANCE_SOURCE_DIR,
|
FE_INSTANCE_SOURCE_DIR,
|
||||||
SENTRY_DSN,
|
SENTRY_DSN,
|
||||||
} = import.meta.compileTime('./build-config-compiletime.ts');
|
} = import.meta.compileTime('./build-config-compiletime.ts');
|
||||||
|
@ -12,7 +11,6 @@ export {
|
||||||
NODE_ENV,
|
NODE_ENV,
|
||||||
BACKEND_URL,
|
BACKEND_URL,
|
||||||
FE_SUBDIRECTORY,
|
FE_SUBDIRECTORY,
|
||||||
FE_BUILD_DIR,
|
|
||||||
FE_INSTANCE_SOURCE_DIR,
|
FE_INSTANCE_SOURCE_DIR,
|
||||||
SENTRY_DSN,
|
SENTRY_DSN,
|
||||||
};
|
};
|
|
@ -2,7 +2,7 @@ const { parseColorMatrix } = require('./tailwind/colors.cjs');
|
||||||
|
|
||||||
/** @type {import('tailwindcss').Config} */
|
/** @type {import('tailwindcss').Config} */
|
||||||
module.exports = {
|
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',
|
darkMode: 'class',
|
||||||
theme: {
|
theme: {
|
||||||
screens: {
|
screens: {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/// <reference types="vitest" />
|
/// <reference types="vitest" />
|
||||||
|
import fs from 'node:fs';
|
||||||
import { fileURLToPath, URL } from 'node:url';
|
import { fileURLToPath, URL } from 'node:url';
|
||||||
|
|
||||||
import react from '@vitejs/plugin-react';
|
import react from '@vitejs/plugin-react';
|
||||||
|
@ -36,6 +37,11 @@ export default defineConfig({
|
||||||
collapseWhitespace: true,
|
collapseWhitespace: true,
|
||||||
removeComments: false,
|
removeComments: false,
|
||||||
},
|
},
|
||||||
|
inject: {
|
||||||
|
data: {
|
||||||
|
snippets: readFileContents('custom/snippets.html'),
|
||||||
|
},
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
react({
|
react({
|
||||||
// Use React plugin in all *.jsx and *.tsx files
|
// Use React plugin in all *.jsx and *.tsx files
|
||||||
|
@ -70,6 +76,9 @@ export default defineConfig({
|
||||||
}, {
|
}, {
|
||||||
src: './src/instance',
|
src: './src/instance',
|
||||||
dest: '.',
|
dest: '.',
|
||||||
|
}, {
|
||||||
|
src: './custom/instance',
|
||||||
|
dest: '.',
|
||||||
}],
|
}],
|
||||||
}),
|
}),
|
||||||
visualizer({
|
visualizer({
|
||||||
|
@ -89,3 +98,12 @@ export default defineConfig({
|
||||||
setupFiles: 'src/jest/test-setup.ts',
|
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