Several changes to allow users to include the content of an arbitrary html page as the front page of a 'shacl-vue deployment, which displays when no data type is selected. - an html page should be put in the distribution root directory - a new config option 'front_page_content' should state the name of that file - updated code in the 'configuration' composable will fetch the content of the html file and render it on the app's front page - no default exists (currently), i.e. default behavior will be what has been the standard behavior before this commit - the vite config was updated for local development to support returning a 404 when a non-existing URL is being accessed, so that the front page rendering code can handle it accordingly
84 lines
2.5 KiB
JavaScript
84 lines
2.5 KiB
JavaScript
// Plugins
|
|
import Components from 'unplugin-vue-components/vite';
|
|
import Vue from '@vitejs/plugin-vue';
|
|
import Vuetify, { transformAssetUrls } from 'vite-plugin-vuetify';
|
|
import ViteFonts from 'unplugin-fonts/vite';
|
|
|
|
// Utilities
|
|
import { defineConfig } from 'vite';
|
|
import { fileURLToPath, URL } from 'node:url';
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
|
|
// Git repo version
|
|
import { execSync } from 'child_process';
|
|
const commitHash = execSync('git rev-parse HEAD').toString().trim();
|
|
const commitHashShort = execSync('git rev-parse --short HEAD')
|
|
.toString()
|
|
.trim();
|
|
const branch = execSync('git rev-parse --abbrev-ref HEAD').toString().trim();
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
plugins: [
|
|
Vue({
|
|
template: { transformAssetUrls },
|
|
}),
|
|
// https://github.com/vuetifyjs/vuetify-loader/tree/master/packages/vite-plugin#readme
|
|
Vuetify(),
|
|
Components(),
|
|
ViteFonts({
|
|
google: {
|
|
families: [
|
|
{
|
|
name: 'Roboto',
|
|
styles: 'wght@100;300;400;500;700;900',
|
|
},
|
|
],
|
|
},
|
|
}),
|
|
{
|
|
name: 'no-spa-fallback-for-html',
|
|
configureServer(server) {
|
|
server.middlewares.use((req, res, next) => {
|
|
if (req.url && req.url.endsWith('.html')) {
|
|
const filePath = path.join(process.cwd(), 'public', req.url);
|
|
if (!fs.existsSync(filePath)) {
|
|
res.statusCode = 404;
|
|
res.end('Not Found');
|
|
return; // stop here
|
|
}
|
|
}
|
|
next();
|
|
});
|
|
},
|
|
},
|
|
],
|
|
define: {
|
|
'process.env': {},
|
|
__COMMIT_HASH__: JSON.stringify(commitHash),
|
|
__COMMIT_HASH_SHORT__: JSON.stringify(commitHashShort),
|
|
__BRANCH__: JSON.stringify(branch),
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
},
|
|
extensions: ['.js', '.json', '.jsx', '.mjs', '.ts', '.tsx', '.vue'],
|
|
},
|
|
build: {
|
|
outDir: 'dist/app',
|
|
emptyOutDir: true,
|
|
sourcemap: true,
|
|
rollupOptions: {
|
|
input: 'index.html',
|
|
},
|
|
},
|
|
server: {
|
|
port: 3000,
|
|
mimeTypes: {
|
|
'.vue': 'application/javascript',
|
|
},
|
|
},
|
|
base: './',
|
|
});
|