Gallery Courses
Project based on React, TypeScript, Webpack and Docker
npm install - install dependencies
npm run start:dev or npm run start:dev:vite - start the server + frontend project in dev mode
npm run start
- Starting a frontend project on the webpack dev servernpm run start:vite
- Starting a frontend project on vitenpm run start:dev
- Starting a frontend project on webpack dev server + backendnpm run start:dev:vite
- Starting a frontend project on vite + backendnpm run start:dev:server
- Start the backend servernpm run build:prod
- Build in prod modenpm run build:dev
- Build in dev mode (not minified)npm run lint:ts
- Checking ts files with a linternpm run lint:ts:fix
- Fixing ts files with a linternpm run lint:scss
- Checking scss style files with a linternpm run lint:scss:fix
- Fixing scss style files with a linternpm run test:unit
- Hack unit tests with jestnpm run test:ui
- Hack screenshot tests with lokinpm run test:ui:ok
- Confirm new screenshotsnpm run test:ui:ci
- Run screenshot tests in CInpm run test:ui:report
- Generate a full report for screenshot testsnpm run test:ui:json
- Generating a json report for screenshot testsnpm run test:ui:html
- Generate HTML report for screenshot testsnpm run storybook
- launch Storybooknpm run storybook:build
- Build a storybook buildnpm run prepare
- precommit hooksnpm run generate:slice
- Script for generating FSD slices
The project was written in accordance with the Feature sliced design methodology
Link to documentation - feature sliced design
The project uses the i18next library to work with translations. Translation files are stored in public/locales.
For comfortable work, we recommend installing the plugin for webstorm/vscode
i18next Documentation - https://react.i18next.com/
The project uses 4 types of tests:
- Regular unit tests for jest -
npm run test:unit
- Tests for components with React testing library -
npm run test:unit
- Screenshot testing with loki
npm run test:ui
- e2e testing with Cypress
npm run test:e2e
More information about tests - testing documentation
The project uses eslint to check typescript code and stylelint to check style files.
Also for strict control of the main architectural principles uses its own eslint plugin eslint-plugin-ulbi-tv-plugin, which contains 3 rules
- path-checker - prohibits the use of absolute imports within one module
- layer-imports - checks the correct use of layers from the point of view of FSD (for example widgets cannot be used in features and entitites)
- public-api-imports - allows imports from other modules only from public api. Has auto fix
npm run lint:ts
- Checking ts files with a linternpm run lint:ts:fix
- Fixing ts files with a linternpm run lint:scss
- Checking scss style files with a linternpm run lint:scss:fix
- Fixing scss style files with a linter
The project describes story cases for each component. Requests to the server are mocked using storybook-addon-mock.
A file with story cases is created next to the component with the extension .stories.tsx
You can start the storybook with the command:
npm run storybook
More about Storybook
Example:
import { ComponentStory, ComponentMeta } from '@storybook/react';
import { ThemeDecorator } from '@/shared/config/storybook/ThemeDecorator/ThemeDecorator';
import { Button, ButtonSize, ThemeButton as ButtonTheme } from './Button';
import { Theme } from '../../const/theme';
export default {
title: 'shared/Button',
component: Button,
argTypes: {
backgroundColor: { control: 'color' },
},
} as ComponentMeta<typeof Button>;
const Template: ComponentStory<typeof Button> = (args) => <Button {...args} />;
export const Primary = Template.bind({});
Primary.args = {
children: 'Text',
};
For development, the project contains 2 configs:
- Webpack - ./config/build
- vite - vite.config.ts
Both collectors are adapted to the main features of the application.
All configuration is stored in /config
- /config/babel - babel
- /config/build - webpack configuration
- /config/jest - test environment configuration
- /config/storybook - storybook configuration
The scripts
folder contains various scripts for refactoring\simplifying code writing\generating reports, etc.
The github actions configuration is located in /.github/workflows. All types of tests, project and storybook assembly, and linting are run in ci.
In precommit hooks we check the project with linters, config in /.h
Build docker images of frontend(webpack)
, run this command in root of project, this
will install all packages of package.json
docker-compose up --build
After of build image, up project
docker-compose up
docker-compose run --rm frontend sh -c "npm run lint:ts:fix"
docker-compose run --rm frontend sh -c "npm run test:unit classNames.test.ts"
docker-compose run -p 8888:8888 --rm frontend sh -c "npm run build:dev"
docker-compose run -p 6006:6006 --rm frontend sh -c "npm run storybook"
docker-compose run -p 8000:8000 --rm frontend sh -c "npm run json-server"
docker-compose run -p 8000:8000 --rm frontend sh -c "npm run start:dev:server"
docker-compose run --rm frontend sh -c "npm run generate:slice features testFeature"
docker-compose run --rm frontend sh -c "npx ts-node ./scripts/refactoring/updateImports.ts"
docker-compose run --rm frontend sh -c "npx ts-node ./scripts/refactoring/createPublicApiForSharedUi.ts"
First cd into the react-typescript-webpack-docker
folder.
cd react-typescript-webpack-docker
Copy node_modules folder from container to host with docker command
docker cp webpack-docker-frontend-1:/app/node_modules/ ./
docker system prune -a