mirror of
https://github.com/koloml/furbooru-tagging-assistant.git
synced 2025-12-23 14:52:59 +00:00
Provide current site name & identifier for build-time modifications
This commit is contained in:
@@ -2,6 +2,8 @@ import { build } from "vite";
|
||||
import { createHash } from "crypto";
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
import { SwapDefinedVariablesPlugin } from "../plugins/swap-defined-variables.js";
|
||||
import { ScssViteReadEnvVariableFunctionPlugin } from "../plugins/scss-read-env-variable-function.js";
|
||||
|
||||
/**
|
||||
* Create the result base file name for the file.
|
||||
@@ -192,6 +194,15 @@ export async function buildScriptsAndStyles(buildOptions) {
|
||||
.get(fileName)
|
||||
?.push(...dependencies);
|
||||
}),
|
||||
ScssViteReadEnvVariableFunctionPlugin(),
|
||||
SwapDefinedVariablesPlugin({
|
||||
envVariable: 'SITE',
|
||||
expectedValue: 'derpibooru',
|
||||
define: {
|
||||
__CURRENT_SITE__: JSON.stringify('derpibooru'),
|
||||
__CURRENT_SITE_NAME__: JSON.stringify('Derpibooru'),
|
||||
}
|
||||
}),
|
||||
]
|
||||
});
|
||||
|
||||
@@ -215,7 +226,11 @@ export async function buildScriptsAndStyles(buildOptions) {
|
||||
},
|
||||
plugins: [
|
||||
wrapScriptIntoIIFE(),
|
||||
]
|
||||
],
|
||||
define: {
|
||||
__CURRENT_SITE__: JSON.stringify('furbooru'),
|
||||
__CURRENT_SITE_NAME__: JSON.stringify('Furbooru'),
|
||||
}
|
||||
});
|
||||
|
||||
return pathsReplacement;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "npm run build:popup && npm run build:extension",
|
||||
"build:derpibooru": "cross-env SITE=derpibooru npm run build",
|
||||
"build:popup": "vite build",
|
||||
"build:extension": "node build-extension.js",
|
||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||
|
||||
@@ -1,21 +1,38 @@
|
||||
import { sveltekit } from '@sveltejs/kit/vite';
|
||||
import { defineConfig } from 'vitest/config';
|
||||
import { ScssViteReadEnvVariableFunctionPlugin } from "./.vite/plugins/scss-read-env-variable-function";
|
||||
import { SwapDefinedVariablesPlugin } from "./.vite/plugins/swap-defined-variables";
|
||||
|
||||
export default defineConfig({
|
||||
build: {
|
||||
// SVGs imported from the FA6 don't need to be inlined!
|
||||
assetsInlineLimit: 0
|
||||
},
|
||||
plugins: [
|
||||
sveltekit(),
|
||||
],
|
||||
test: {
|
||||
globals: true,
|
||||
environment: 'jsdom',
|
||||
exclude: ['**/node_modules/**', '.*\\.d\\.ts$', '.*\\.spec\\.ts$'],
|
||||
coverage: {
|
||||
reporter: ['text', 'html'],
|
||||
include: ['src/lib/**/*.{js,ts}'],
|
||||
export default defineConfig(() => {
|
||||
return {
|
||||
build: {
|
||||
// SVGs imported from the FA6 don't need to be inlined!
|
||||
assetsInlineLimit: 0
|
||||
},
|
||||
plugins: [
|
||||
sveltekit(),
|
||||
ScssViteReadEnvVariableFunctionPlugin(),
|
||||
SwapDefinedVariablesPlugin({
|
||||
envVariable: 'SITE',
|
||||
expectedValue: 'derpibooru',
|
||||
define: {
|
||||
__CURRENT_SITE__: JSON.stringify('derpibooru'),
|
||||
__CURRENT_SITE_NAME__: JSON.stringify('Derpibooru'),
|
||||
}
|
||||
}),
|
||||
],
|
||||
test: {
|
||||
globals: true,
|
||||
environment: 'jsdom',
|
||||
exclude: ['**/node_modules/**', '.*\\.d\\.ts$', '.*\\.spec\\.ts$'],
|
||||
coverage: {
|
||||
reporter: ['text', 'html'],
|
||||
include: ['src/lib/**/*.{js,ts}'],
|
||||
}
|
||||
},
|
||||
define: {
|
||||
__CURRENT_SITE__: JSON.stringify('furbooru'),
|
||||
__CURRENT_SITE_NAME__: JSON.stringify('Furbooru'),
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user