diff --git a/.npmrc b/.npmrc deleted file mode 100644 index cafe685..0000000 --- a/.npmrc +++ /dev/null @@ -1 +0,0 @@ -package-lock=true diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index fc5ced8..0000000 --- a/.prettierignore +++ /dev/null @@ -1,7 +0,0 @@ -# Ignore artifacts: -build -dist -coverage -stubs -logs -d-scripts \ No newline at end of file diff --git a/.prettierrc.json b/.prettierrc.json deleted file mode 100644 index b5bbaff..0000000 --- a/.prettierrc.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "tabWidth": 2, - "semi": true, - "jsxBracketSameLine": true, - "arrowParens": "avoid", - "singleQuote": true -} diff --git a/@types/emotion.d.ts b/@types/emotion.d.ts deleted file mode 100644 index 66b1208..0000000 --- a/@types/emotion.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import '@emotion/react'; - -import { lightTheme } from '../src/app.theme'; - -declare module '@emotion/react' { - export interface Theme { - colors: typeof lightTheme.colors, - shadows: typeof lightTheme.shadows - } -} diff --git a/@types/index.d.ts b/@types/index.d.ts deleted file mode 100644 index 9421318..0000000 --- a/@types/index.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -declare const IS_PROD: string; - -declare module '*.svg' { - const value: string; - - export default value; -} - -declare module '*.jpg' { - const value: string; - - export default value; -} - -declare module '*.png' { - const value: string; - - export default value; -} diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 861c015..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,31 +0,0 @@ -pipeline { - agent { - docker { - image 'node:20' - } - } - - stages { - stage('install') { - steps { - sh 'node -v' - sh 'npm -v' - sh 'npm ci' - } - } - - stage('eslint') { - steps { - sh 'npm run eslint' - } - } - - stage('clean-all') { - steps { - sh 'rm -rf .[!.]*' - sh 'rm -rf ./*' - sh 'ls -a' - } - } - } -} \ No newline at end of file diff --git a/VITE_BUILD_GUIDE.md b/VITE_BUILD_GUIDE.md new file mode 100644 index 0000000..6c572a3 --- /dev/null +++ b/VITE_BUILD_GUIDE.md @@ -0,0 +1,82 @@ +# 🚀 Production сборка с Vite + +## ✅ Как работает + +### Встроенные переменные Vite + +Vite автоматически определяет режим сборки: +- **Dev**: `mode = 'development'` +- **Production**: `mode = 'production'` + +В `vite.config.ts`: +```typescript +export default defineConfig(({ mode }) => { + const isProd = mode === 'production'; + + return { + base: isProd + ? 'https://static.brojs.ru/landing/main/' // Production CDN + : '/', // Dev локально + // ... + } +}); +``` + +## 🌐 Команды + +### Dev режим +```bash +npm start # mode = 'development' +npm run dev # mode = 'development' +``` +- Base: `/` +- URL: `http://localhost:8099/` +- Ассеты: локальные пути + +### Production сборка +```bash +npm run build # mode = 'production' +``` +- Base: `https://static.brojs.ru/landing/main/` +- Все пути автоматически заменяются на CDN! + +## 📦 Результат production сборки + +### index.html (главная) +```html + +``` + +### terms.html (Terms) +```html + +``` + +## 🎯 Кроссплатформенность + +✅ **Windows**: работает +✅ **Linux**: работает +✅ **macOS**: работает + +Vite использует встроенный параметр `mode`, который работает **везде без дополнительных пакетов**! + +## 🔧 Альтернативный способ (если нужен кастомный env) + +Если понадобится установить свои переменные: + +### Установи cross-env +```bash +npm install --save-dev cross-env +``` + +### Обнови package.json +```json +{ + "scripts": { + "build": "cross-env NODE_ENV=production vite build" + } +} +``` + +Но это **не нужно** для нашего случая! Vite сам всё делает правильно! ✨ + diff --git a/babel.config.js b/babel.config.js deleted file mode 100644 index faa86eb..0000000 --- a/babel.config.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - presets: [ - ['@babel/preset-env', { targets: { node: 'current' } }], - '@babel/preset-typescript', - ], -}; diff --git a/d-scripts/re-run.sh b/d-scripts/re-run.sh deleted file mode 100644 index 37cc50c..0000000 --- a/d-scripts/re-run.sh +++ /dev/null @@ -1,2 +0,0 @@ -sh stop.sh; -sh up-nginx.sh; \ No newline at end of file diff --git a/d-scripts/stop.sh b/d-scripts/stop.sh deleted file mode 100644 index dcd9568..0000000 --- a/d-scripts/stop.sh +++ /dev/null @@ -1 +0,0 @@ -docker stop adminka_nginx2; diff --git a/d-scripts/up-nginx.sh b/d-scripts/up-nginx.sh deleted file mode 100644 index 6a5ac30..0000000 --- a/d-scripts/up-nginx.sh +++ /dev/null @@ -1 +0,0 @@ -docker run --name adminka_nginx2 -v $PWD/nginx.conf:/etc/nginx/nginx.conf:ro -v $PWD/dist:/usr/share/nginx/html --rm -d -p 3072:80 nginx; \ No newline at end of file diff --git a/eslint.config.mjs b/eslint.config.mjs deleted file mode 100644 index c692093..0000000 --- a/eslint.config.mjs +++ /dev/null @@ -1,13 +0,0 @@ -import globals from "globals"; -import pluginJs from "@eslint/js"; -import tseslint from "typescript-eslint"; -import pluginReact from "eslint-plugin-react"; - - -export default [ - {files: ["**/*.{js,mjs,cjs,ts,jsx,tsx}"]}, - {languageOptions: { globals: globals.browser }}, - pluginJs.configs.recommended, - ...tseslint.configs.recommended, - pluginReact.configs.flat.recommended, -]; \ No newline at end of file diff --git a/ijl.config.js b/ijl.config.js deleted file mode 100644 index fc85bd5..0000000 --- a/ijl.config.js +++ /dev/null @@ -1,88 +0,0 @@ -/* eslint-disable @typescript-eslint/no-require-imports */ -/* eslint-disable no-undef */ -const path = require('path'); -const pkg = require('./package'); -const HtmlWebpackPlugin = require('html-webpack-plugin'); -const MiniCssExtractPlugin = require('mini-css-extract-plugin'); -const webpack = require('webpack'); - -const isProd = process.env.NODE_ENV === 'production'; - -module.exports = { - apiPath: 'stubs/api', - apps: { - main: { - version: 'master', - name: 'cleanName', - }, - }, - webpackConfig: { - entry: { - index: './src/index.tsx', - terms: './src/terms.js', // Entry для стилей terms - }, - output: { - publicPath: isProd - ? 'https://static.brojs.ru/landing/main/' - : `/static/${pkg.name}/${process.env.VERSION || pkg.version}/`, - filename: '[name].js?[contenthash]', - }, - module: { - rules: [ - { - test: /\.module\.scss$/, - use: [ - isProd ? MiniCssExtractPlugin.loader : 'style-loader', - { - loader: 'css-loader', - options: { - modules: { - localIdentName: isProd ? '[hash:base64:8]' : '[name]__[local]--[hash:base64:5]', - }, - }, - }, - 'sass-loader' - ], - }, - { - test: /\.scss$/, - exclude: /\.module\.scss$/, - use: [ - isProd ? MiniCssExtractPlugin.loader : 'style-loader', - 'css-loader', - 'sass-loader' - ], - }, - ], - }, - plugins: [ - // Главная страница (с React) - new HtmlWebpackPlugin({ - template: './src/index.ejs', - filename: 'index.html', - chunks: ['index'], - }), - // Terms страница (статика + SCSS) - new HtmlWebpackPlugin({ - template: './src/terms.html', - filename: 'terms.html', - chunks: isProd ? [] : ['terms'], // В production не нужен JS - cssPath: isProd - ? 'https://static.brojs.ru/landing/main/terms.css' - : `/static/${pkg.name}/${process.env.VERSION || pkg.version}/terms.css`, - }), - // Извлечение CSS в отдельные файлы для production - ...(isProd ? [ - new MiniCssExtractPlugin({ - filename: '[name].css', - }) - ] : []), - new webpack.DefinePlugin({ - IS_PROD: process.env.NODE_ENV === 'production', - }), - ], - }, - navigations: {}, - features: {}, - config: {}, -}; diff --git a/src/index.ejs b/index.html similarity index 52% rename from src/index.ejs rename to index.html index aa7e4e6..e48e5a8 100644 --- a/src/index.ejs +++ b/index.html @@ -3,17 +3,23 @@
- - -