mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
chore: Add build version as banner to outputted js and css chat files (no-changelog) (#16629)
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1,10 +1,11 @@
|
|||||||
import { defineConfig, mergeConfig } from 'vite';
|
import { defineConfig, mergeConfig, PluginOption } from 'vite';
|
||||||
import { resolve } from 'path';
|
import { resolve } from 'path';
|
||||||
import { renameSync } from 'fs';
|
import { renameSync, writeFileSync, readFileSync } from 'fs';
|
||||||
import vue from '@vitejs/plugin-vue';
|
import vue from '@vitejs/plugin-vue';
|
||||||
import icons from 'unplugin-icons/vite';
|
import icons from 'unplugin-icons/vite';
|
||||||
import dts from 'vite-plugin-dts';
|
import dts from 'vite-plugin-dts';
|
||||||
import { vitestConfig } from '@n8n/vitest-config/frontend';
|
import { vitestConfig } from '@n8n/vitest-config/frontend';
|
||||||
|
import pkg from './package.json';
|
||||||
import iconsResolver from 'unplugin-icons/resolver';
|
import iconsResolver from 'unplugin-icons/resolver';
|
||||||
import components from 'unplugin-vue-components/vite';
|
import components from 'unplugin-vue-components/vite';
|
||||||
|
|
||||||
@@ -12,6 +13,8 @@ const includeVue = process.env.INCLUDE_VUE === 'true';
|
|||||||
const srcPath = resolve(__dirname, 'src');
|
const srcPath = resolve(__dirname, 'src');
|
||||||
const packagesDir = resolve(__dirname, '..', '..', '..');
|
const packagesDir = resolve(__dirname, '..', '..', '..');
|
||||||
|
|
||||||
|
const banner = `/*! Package version @n8n/chat@${pkg.version} */`;
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default mergeConfig(
|
export default mergeConfig(
|
||||||
defineConfig({
|
defineConfig({
|
||||||
@@ -49,6 +52,19 @@ export default mergeConfig(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'inject-build-version',
|
||||||
|
closeBundle() {
|
||||||
|
const cssPath = resolve(__dirname, 'dist', 'style.css');
|
||||||
|
try {
|
||||||
|
const cssContent = readFileSync(cssPath, 'utf-8');
|
||||||
|
const updatedCssContent = banner + '\n' + cssContent;
|
||||||
|
writeFileSync(cssPath, updatedCssContent, 'utf-8');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to inject build version into CSS file:', error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: [
|
alias: [
|
||||||
@@ -86,6 +102,8 @@ export default mergeConfig(
|
|||||||
external: includeVue ? [] : ['vue'],
|
external: includeVue ? [] : ['vue'],
|
||||||
output: {
|
output: {
|
||||||
exports: 'named',
|
exports: 'named',
|
||||||
|
// inject banner on top of all JS files
|
||||||
|
banner,
|
||||||
// Provide global variables to use in the UMD build
|
// Provide global variables to use in the UMD build
|
||||||
// for externalized deps
|
// for externalized deps
|
||||||
globals: includeVue
|
globals: includeVue
|
||||||
|
|||||||
Reference in New Issue
Block a user