Co-authored-by: Ivan <84693047+exact01@users.noreply.github.com>
This commit is contained in:
kastov 2024-12-02 20:09:46 +03:00
parent 19ab4ead7e
commit 7df707e36a
4 changed files with 41 additions and 5 deletions

27
.github/workflows/deploy-lib.yml vendored Normal file
View file

@ -0,0 +1,27 @@
name: Deploy lib
on:
push:
tags:
- '*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '22.x'
registry-url: 'https://npm.pkg.github.com'
- name: Install dependencies and build
working-directory: './'
run: npm i && npm run start:build
- name: Publish package
working-directory: './'
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GH_TOKEN }}

View file

@ -1,8 +1,8 @@
{ {
"name": "@remnawave/frontend", "name": "@remnawave/frontend",
"private": true, "private": false,
"type": "module", "type": "module",
"version": "0.0.0", "version": "0.0.1",
"scripts": { "scripts": {
"start:dev": "vite", "start:dev": "vite",
"start:build": "NODE_ENV=production tsc && vite build", "start:build": "NODE_ENV=production tsc && vite build",
@ -106,4 +106,4 @@
"inquirer": "9.3.5" "inquirer": "9.3.5"
} }
} }
} }

View file

@ -5,8 +5,16 @@ import { logoutEvents } from '../emitters/emit-logout'
let authorizationToken = '' let authorizationToken = ''
let BASE_DOMAIN = __DOMAIN_BACKEND__
const isDev = __NODE_ENV__ === 'development'
if (isDev) {
BASE_DOMAIN = __DOMAIN_BACKEND__
} else {
BASE_DOMAIN = window.location.origin
}
export const instance = axios.create({ export const instance = axios.create({
baseURL: __DOMAIN_BACKEND__, baseURL: BASE_DOMAIN,
headers: { headers: {
'Content-type': 'application/json', 'Content-type': 'application/json',
Accept: 'application/json' Accept: 'application/json'

View file

@ -12,6 +12,7 @@ export default defineConfig({
plugins: [react(), visualizer() as PluginOption, tsconfigPaths()], plugins: [react(), visualizer() as PluginOption, tsconfigPaths()],
build: { build: {
target: 'esNext', target: 'esNext',
outDir: 'dist',
rollupOptions: { rollupOptions: {
output: { output: {
manualChunks: { manualChunks: {
@ -33,7 +34,7 @@ export default defineConfig({
} }
}, },
define: { define: {
__DOMAIN_BACKEND__: JSON.stringify(process.env.DOMAIN_BACKEND).trim(), __DOMAIN_BACKEND__: JSON.stringify(process.env.DOMAIN_BACKEND || 'example.com').trim(),
__NODE_ENV__: JSON.stringify(process.env.NODE_ENV).trim() __NODE_ENV__: JSON.stringify(process.env.NODE_ENV).trim()
}, },
server: { server: {