moved from vite to webpack + babel, since vite '**unusable**'

This commit is contained in:
Maksim Skobaro 2024-10-20 06:36:17 +03:00
parent d4f61438eb
commit 212249becd
10 changed files with 5244 additions and 2169 deletions

View File

@ -1,18 +0,0 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}

12
web/babel.config.json Normal file
View File

@ -0,0 +1,12 @@
{
"presets": [
["@babel/preset-env", {"modules": false}],
"@babel/preset-react",
"@babel/preset-typescript"
],
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties"],
["@babel/plugin-transform-typescript"]
]
}

7214
web/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,35 +1,35 @@
{ {
"name": "web", "name": "web",
"version": "1.0.0",
"private": true, "private": true,
"version": "0.0.1",
"type": "module",
"scripts": { "scripts": {
"dev": "vite", "build" : "webpack --mode production",
"build": "tsc -b && vite build", "dev": "webpack-dev-server --mode development"
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
}, },
"dependencies": { "dependencies": {
"@react-buddy/ide-toolbox": "^2.4.0",
"axios": "^1.7.7", "axios": "^1.7.7",
"bootstrap": "^5.3.3", "bootstrap": "^5.3.3",
"mobx": "^6.13.1", "mobx": "^6.13.1",
"mobx-react": "^9.1.1", "mobx-react": "^9.1.1",
"mobx-state-router": "^6.0.1", "mobx-state-router": "^6.0.1",
"react": "^18.3.1", "react": "^18.2.0",
"react-bootstrap": "^2.10.4", "react-bootstrap": "^2.10.4",
"react-dom": "^18.3.1" "react-dom": "^18.2.0"
}, },
"devDependencies": { "devDependencies": {
"@types/react": "^18.3.3", "@babel/plugin-proposal-decorators": "^7.25.7",
"@types/react-dom": "^18.3.0", "@babel/preset-env": "^7.25.8",
"@typescript-eslint/eslint-plugin": "^7.15.0", "@babel/preset-react": "^7.25.7",
"@typescript-eslint/parser": "^7.15.0", "@types/react": "^18.2.0",
"@vitejs/plugin-react": "^4.3.1", "@types/react-dom": "^18.2.0",
"eslint": "^8.57.0", "@types/webpack": "^5.28.5",
"eslint-plugin-react-hooks": "^4.6.2", "css-loader": "^7.1.2",
"eslint-plugin-react-refresh": "^0.4.7", "html-webpack-plugin": "^5.6.2",
"typescript": "^5.2.2", "style-loader": "^4.0.0",
"vite": "^5.3.4" "ts-loader": "^9.5.1",
"typescript": "^5.6.3",
"webpack": "^5.95.0",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.1.0"
} }
} }

View File

@ -3,10 +3,10 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>TDMS</title> <title>TDMS</title>
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
<script type="module" src="/src/Application.tsx"></script>
</body> </body>
</html> </html>

View File

@ -1,28 +0,0 @@
{
"compilerOptions": {
"composite": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"allowSyntheticDefaultImports": true,
},
"include": ["src"]
}

View File

@ -1,11 +1,24 @@
{ {
"files": [], "compilerOptions": {
"references": [ "outDir": "./dist",
{ "target": "ES5",
"path": "./tsconfig.app.json" "module": "ES6",
}, "jsx": "react-jsx",
{ "sourceMap": false,
"path": "./tsconfig.node.json" "useDefineForClassFields": true,
} "moduleResolution": "Bundler",
] "composite": true,
} "resolveJsonModule": true,
/* enabling decorators */
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
/* lint */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitAny": true,
"allowSyntheticDefaultImports": true
}
}

View File

@ -1,13 +0,0 @@
{
"compilerOptions": {
"composite": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true,
"strict": true,
"noEmit": true
},
"include": ["vite.config.ts"]
}

View File

@ -1,15 +0,0 @@
import {defineConfig} from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({
esbuild: {
tsconfigRaw: {
compilerOptions: {
experimentalDecorators: true,
},
},
},
plugins: [
react()
],
})

40
web/webpack.config.js Normal file
View File

@ -0,0 +1,40 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
mode: 'none',
entry: {
app: path.join(__dirname, 'src', 'Application.tsx')
},
target: 'web',
resolve: {
extensions: ['.ts', '.tsx', '.js']
},
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: '/node_modules/'
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
],
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist')
},
devServer: {
static: path.join(__dirname, "dist"),
compress: false,
port: 8081,
},
plugins: [
new HtmlWebpackPlugin({
template: path.join(__dirname, 'src', 'index.html')
})
]
}