Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
9d94591d
Commit
9d94591d
authored
Dec 19, 2024
by
tom
Committed by
tom goriunov
Dec 23, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
append hash to sprite file name base on its content
parent
dbb246bd
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
40 additions
and
8 deletions
+40
-8
.gitignore
.gitignore
+1
-0
Dockerfile
Dockerfile
+5
-4
app.ts
configs/app/app.ts
+2
-0
build_sprite.sh
deploy/scripts/build_sprite.sh
+21
-0
BUILD-TIME_ENVS.md
docs/BUILD-TIME_ENVS.md
+1
-0
package.json
package.json
+1
-1
dev.preset.sh
tools/scripts/dev.preset.sh
+2
-1
dev.sh
tools/scripts/dev.sh
+2
-1
pw.sh
tools/scripts/pw.sh
+2
-0
IconSvg.tsx
ui/shared/IconSvg.tsx
+3
-1
No files found.
.gitignore
View file @
9d94591d
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
/public/assets/envs.js
/public/assets/envs.js
/public/assets/configs
/public/assets/configs
/public/icons/sprite.svg
/public/icons/sprite.svg
/public/icons/sprite.*.svg
/public/icons/README.md
/public/icons/README.md
/analyze
/analyze
...
...
Dockerfile
View file @
9d94591d
...
@@ -56,9 +56,11 @@ WORKDIR /app
...
@@ -56,9 +56,11 @@ WORKDIR /app
COPY
--from=deps /app/node_modules ./node_modules
COPY
--from=deps /app/node_modules ./node_modules
COPY
. .
COPY
. .
# Generate .env.registry with ENVs list and save build args into .env file
# Build SVG sprite and generate .env.registry with ENVs list and save build args into .env file
COPY
--chmod=755 ./deploy/scripts/collect_envs.sh ./
RUN
set
-a
&&
\
RUN
./collect_envs.sh ./docs/ENVS.md
source
./deploy/scripts/build_sprite.sh
&&
\
./deploy/scripts/collect_envs.sh ./docs/ENVS.md
&&
\
set
+a
# Next.js collects completely anonymous telemetry data about general usage.
# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Learn more here: https://nextjs.org/telemetry
...
@@ -66,7 +68,6 @@ RUN ./collect_envs.sh ./docs/ENVS.md
...
@@ -66,7 +68,6 @@ RUN ./collect_envs.sh ./docs/ENVS.md
# ENV NEXT_TELEMETRY_DISABLED 1
# ENV NEXT_TELEMETRY_DISABLED 1
# Build app for production
# Build app for production
RUN
yarn svg:build-sprite
RUN
yarn build
RUN
yarn build
...
...
configs/app/app.ts
View file @
9d94591d
...
@@ -10,6 +10,7 @@ const baseUrl = [
...
@@ -10,6 +10,7 @@ const baseUrl = [
appPort
&&
'
:
'
+
appPort
,
appPort
&&
'
:
'
+
appPort
,
].
filter
(
Boolean
).
join
(
''
);
].
filter
(
Boolean
).
join
(
''
);
const
isDev
=
getEnvValue
(
'
NEXT_PUBLIC_APP_ENV
'
)
===
'
development
'
;
const
isDev
=
getEnvValue
(
'
NEXT_PUBLIC_APP_ENV
'
)
===
'
development
'
;
const
spriteHash
=
getEnvValue
(
'
NEXT_PUBLIC_ICON_SPRITE_HASH
'
);
const
app
=
Object
.
freeze
({
const
app
=
Object
.
freeze
({
isDev
,
isDev
,
...
@@ -18,6 +19,7 @@ const app = Object.freeze({
...
@@ -18,6 +19,7 @@ const app = Object.freeze({
port
:
appPort
,
port
:
appPort
,
baseUrl
,
baseUrl
,
useProxy
:
getEnvValue
(
'
NEXT_PUBLIC_USE_NEXT_JS_PROXY
'
)
===
'
true
'
,
useProxy
:
getEnvValue
(
'
NEXT_PUBLIC_USE_NEXT_JS_PROXY
'
)
===
'
true
'
,
spriteHash
,
});
});
export
default
app
;
export
default
app
;
deploy/scripts/build_sprite.sh
0 → 100755
View file @
9d94591d
#!/bin/bash
yarn icons build
-i
./icons
-o
./public/icons
--optimize
# Skip hash creation and renaming for playwright environment
if
[
"
$NEXT_PUBLIC_APP_ENV
"
!=
"pw"
]
;
then
# Generate hash from the sprite file
HASH
=
$(
md5sum
./public/icons/sprite.svg |
cut
-d
' '
-f1
|
head
-c
8
)
# Remove old sprite files
rm
-f
./public/icons/sprite.
*
.svg
# Rename the new sprite file
mv
./public/icons/sprite.svg
"./public/icons/sprite.
${
HASH
}
.svg"
export
NEXT_PUBLIC_ICON_SPRITE_HASH
=
${
HASH
}
echo
"SVG sprite created: sprite.
${
HASH
}
.svg"
else
echo
"SVG sprite created: sprite.svg (hash skipped for playwright environment)"
fi
\ No newline at end of file
docs/BUILD-TIME_ENVS.md
View file @
9d94591d
...
@@ -7,3 +7,4 @@ These variables are passed to the app during the image build process. They canno
...
@@ -7,3 +7,4 @@ These variables are passed to the app during the image build process. They canno
| NEXT_PUBLIC_GIT_COMMIT_SHA |
`string`
| SHA of the latest commit in the branch from which image is built | false |
`29d0613e`
|
| NEXT_PUBLIC_GIT_COMMIT_SHA |
`string`
| SHA of the latest commit in the branch from which image is built | false |
`29d0613e`
|
| NEXT_PUBLIC_GIT_TAG |
`string`
| Git tag of the latest commit in the branch from which image is built | true |
`v1.0.0`
|
| NEXT_PUBLIC_GIT_TAG |
`string`
| Git tag of the latest commit in the branch from which image is built | true |
`v1.0.0`
|
| NEXT_OPEN_TELEMETRY_ENABLED |
`boolean`
| Enables OpenTelemetry SDK | true |
`true`
|
| NEXT_OPEN_TELEMETRY_ENABLED |
`boolean`
| Enables OpenTelemetry SDK | true |
`true`
|
| NEXT_PUBLIC_ICON_SPRITE_HASH |
`string`
| Hash post-fix of the SVG sprite file (generated automatically during the sprite build) |
`08be4b10`
|
`true`
|
package.json
View file @
9d94591d
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
"lint:envs-validator:test"
:
"cd ./deploy/tools/envs-validator && ./test.sh"
,
"lint:envs-validator:test"
:
"cd ./deploy/tools/envs-validator && ./test.sh"
,
"prepare"
:
"husky install"
,
"prepare"
:
"husky install"
,
"svg:format"
:
"svgo -r ./icons"
,
"svg:format"
:
"svgo -r ./icons"
,
"svg:build-sprite"
:
"
icons build -i ./icons -o ./public/icons --optimize
"
,
"svg:build-sprite"
:
"
./deploy/scripts/build_sprite.sh
"
,
"test:pw"
:
"./tools/scripts/pw.sh"
,
"test:pw"
:
"./tools/scripts/pw.sh"
,
"test:pw:local"
:
"export NODE_PATH=$(pwd)/node_modules && yarn test:pw"
,
"test:pw:local"
:
"export NODE_PATH=$(pwd)/node_modules && yarn test:pw"
,
"test:pw:docker"
:
"docker run --rm --ipc=host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:v1.49.0-noble ./tools/scripts/pw.docker.sh"
,
"test:pw:docker"
:
"docker run --rm --ipc=host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:v1.49.0-noble ./tools/scripts/pw.docker.sh"
,
...
...
tools/scripts/dev.preset.sh
View file @
9d94591d
...
@@ -19,13 +19,14 @@ dotenv \
...
@@ -19,13 +19,14 @@ dotenv \
-e
$config_file
\
-e
$config_file
\
--
bash
-c
'./deploy/scripts/download_assets.sh ./public/assets/configs'
--
bash
-c
'./deploy/scripts/download_assets.sh ./public/assets/configs'
yarn svg:build-sprite
source
./deploy/scripts/build_sprite.sh
echo
""
echo
""
# generate envs.js file and run the app
# generate envs.js file and run the app
dotenv
\
dotenv
\
-v
NEXT_PUBLIC_GIT_COMMIT_SHA
=
$(
git rev-parse
--short
HEAD
)
\
-v
NEXT_PUBLIC_GIT_COMMIT_SHA
=
$(
git rev-parse
--short
HEAD
)
\
-v
NEXT_PUBLIC_GIT_TAG
=
$(
git describe
--tags
--abbrev
=
0
)
\
-v
NEXT_PUBLIC_GIT_TAG
=
$(
git describe
--tags
--abbrev
=
0
)
\
-v
NEXT_PUBLIC_ICON_SPRITE_HASH
=
"
${
NEXT_PUBLIC_ICON_SPRITE_HASH
}
"
\
-e
$config_file
\
-e
$config_file
\
-e
$secrets_file
\
-e
$secrets_file
\
--
bash
-c
'./deploy/scripts/make_envs_script.sh && next dev -p $NEXT_PUBLIC_APP_PORT'
|
--
bash
-c
'./deploy/scripts/make_envs_script.sh && next dev -p $NEXT_PUBLIC_APP_PORT'
|
...
...
tools/scripts/dev.sh
View file @
9d94591d
...
@@ -8,13 +8,14 @@ dotenv \
...
@@ -8,13 +8,14 @@ dotenv \
-e
.env
\
-e
.env
\
--
bash
-c
'./deploy/scripts/download_assets.sh ./public/assets/configs'
--
bash
-c
'./deploy/scripts/download_assets.sh ./public/assets/configs'
yarn svg:build-sprite
source
./deploy/scripts/build_sprite.sh
echo
""
echo
""
# generate envs.js file and run the app
# generate envs.js file and run the app
dotenv
\
dotenv
\
-v
NEXT_PUBLIC_GIT_COMMIT_SHA
=
$(
git rev-parse
--short
HEAD
)
\
-v
NEXT_PUBLIC_GIT_COMMIT_SHA
=
$(
git rev-parse
--short
HEAD
)
\
-v
NEXT_PUBLIC_GIT_TAG
=
$(
git describe
--tags
--abbrev
=
0
)
\
-v
NEXT_PUBLIC_GIT_TAG
=
$(
git describe
--tags
--abbrev
=
0
)
\
-v
NEXT_PUBLIC_ICON_SPRITE_HASH
=
"
${
NEXT_PUBLIC_ICON_SPRITE_HASH
}
"
\
-e
.env.secrets
\
-e
.env.secrets
\
-e
.env.development.local
\
-e
.env.development.local
\
-e
.env.local
\
-e
.env.local
\
...
...
tools/scripts/pw.sh
View file @
9d94591d
...
@@ -8,6 +8,8 @@ dotenv \
...
@@ -8,6 +8,8 @@ dotenv \
-e
$config_file
\
-e
$config_file
\
--
bash
-c
'./deploy/scripts/make_envs_script.sh ./playwright/envs.js'
--
bash
-c
'./deploy/scripts/make_envs_script.sh ./playwright/envs.js'
# Important to set this variable here, so the sprite will be built correctly
export
NEXT_PUBLIC_APP_ENV
=
pw
yarn svg:build-sprite
yarn svg:build-sprite
# Check if the "--affected" argument is present in the script args
# Check if the "--affected" argument is present in the script args
...
...
ui/shared/IconSvg.tsx
View file @
9d94591d
...
@@ -3,7 +3,9 @@ import { Skeleton, chakra } from '@chakra-ui/react';
...
@@ -3,7 +3,9 @@ import { Skeleton, chakra } from '@chakra-ui/react';
import
{
type
IconName
}
from
'
public/icons/name
'
;
import
{
type
IconName
}
from
'
public/icons/name
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
export
const
href
=
'
/icons/sprite.svg
'
;
import
config
from
'
configs/app
'
;
export
const
href
=
config
.
app
.
spriteHash
?
`/icons/sprite.
${
config
.
app
.
spriteHash
}
.svg`
:
'
/icons/sprite.svg
'
;
export
{
IconName
};
export
{
IconName
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment