moving to vite as build system 🎉

This commit is contained in:
weakmap@gmail.com
2022-12-19 21:44:10 +01:00
parent e155e992d4
commit 4785cf797d
39 changed files with 289 additions and 1821 deletions

View File

@@ -66,7 +66,7 @@ For the frontend, run:
```shell
yarn run dev
```
You should now be able to access _Fredy_ from your browser. Go to `http://localhost:9000`.
You should now be able to access _Fredy_ from your browser. Check your Terminal to see what port the frontend is running on.
### Running Tests
To run the tests, run

View File

@@ -4,7 +4,7 @@
<meta charset="UTF-8"
name="viewport"
content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2/dist/semantic.min.css">
<meta name="google" content="notranslate">
<title>Fredy</title>
@@ -13,5 +13,5 @@
<div id="fredy" style="position: absolute;top: 0;left: 0;right: 0;bottom: 0;"></div>
</body>
<script src="fredy.bundle.js"></script>
<script type="module" src="/ui/src/Index.jsx"></script>
</html>

View File

@@ -1,15 +1,12 @@
{
"name": "fredy",
"version": "5.9.0",
"version": "6.0.0",
"description": "[F]ind [R]eal [E]states [d]amn eas[y].",
"scripts": {
"start": "node index.js",
"dev": "run-script-os",
"dev:win32": "yarn && set BUILD_DEV='true' && set NODE_ENV='development' && webpack serve --progress --color --config ./webpack.dev.js",
"dev:default": "yarn && export BUILD_DEV='true' && export NODE_ENV='development' && webpack serve --progress --color --config ./webpack.dev.js",
"prod": "run-script-os",
"prod:win32": "set BUILD_DEV='false' && webpack --node-env=production --config ./webpack.prod.js",
"prod:default": "export BUILD_DEV='false' && webpack --node-env=production --config ./webpack.prod.js",
"dev": "yarn && rm -rf ./ui/public/* && vite",
"ui": "rm -rf ./ui/public/* && vite",
"prod": "yarn && vite build --emptyOutDir",
"format": "prettier --write lib/**/*.js ui/src/**/*.js test/**/*.js *.js --single-quote --print-width 120",
"test": "mocha --timeout 3000000 test/**/*.test.js",
"lint": "eslint ./index.js ./lib/**/*.js ./test/**/*.js"
@@ -60,6 +57,7 @@
"@rematch/core": "2.2.0",
"@rematch/loading": "2.1.2",
"@sendgrid/mail": "7.7.0",
"@vitejs/plugin-react": "^3.0.0",
"axios": "1.2.1",
"better-sqlite3": "8.0.1",
"body-parser": "1.20.1",
@@ -85,17 +83,15 @@
"serve-static": "1.15.0",
"slack": "11.0.2",
"string-similarity": "^4.0.4",
"vite": "^4.0.2",
"x-ray": "2.3.4"
},
"devDependencies": {
"@babel/core": "^7.20.5",
"@babel/eslint-parser": "^7.19.1",
"@babel/preset-env": "7.20.2",
"@babel/preset-react": "7.18.6",
"babel-loader": "9.1.0",
"chai": "4.3.7",
"clean-webpack-plugin": "4.0.0",
"copy-webpack-plugin": "11.0.0",
"css-loader": "6.7.3",
"eslint": "^8.30.0",
"eslint-config-prettier": "8.5.0",
@@ -110,12 +106,7 @@
"prettier": "2.8.1",
"proxyquire": "2.1.3",
"redux-logger": "3.0.6",
"run-script-os": "^1.1.6",
"style-loader": "3.3.1",
"url-loader": "4.1.1",
"webpack": "5.75.0",
"webpack-cli": "5.0.1",
"webpack-dev-server": "4.11.1",
"webpack-merge": "5.8.0"
"url-loader": "4.1.1"
}
}

View File

@@ -7,7 +7,7 @@ import ToastsContainer from './components/toasts/ToastContainer';
import JobMutation from './views/jobs/mutation/JobMutation';
import UserMutator from './views/user/mutation/UserMutator';
import ToastContext from './components/toasts/ToastContext';
import JobInsight from './views/jobs/insights/JobInsight';
import JobInsight from './views/jobs/insights/JobInsight.jsx';
import { useDispatch, useSelector } from 'react-redux';
import useToast from './components/toasts/useToast';
import { Switch, Redirect } from 'react-router-dom';

23
vite.config.js Normal file
View File

@@ -0,0 +1,23 @@
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
// https://vitejs.dev/config/
export default defineConfig({
base: '',
build: {
chunkSizeWarningLimit: 9999999,
outDir: './ui/public',
},
plugins: [react()],
server: {
proxy: {
'/api': {
target: {
host: '0.0.0.0',
protocol: 'http:',
port: 9998,
},
},
},
},
});

View File

@@ -1,39 +0,0 @@
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const path = require('path');
module.exports = {
entry: path.join(__dirname, 'ui', 'src') + '/Index.js',
resolve: {
extensions: ['.js'],
},
plugins: [
new CleanWebpackPlugin(),
new CopyPlugin({
patterns: [{ from: path.join(__dirname, 'ui', 'src') + '/index.html', to: path.join(__dirname, 'ui', 'public') }],
}),
],
output: {
path: path.join(__dirname, 'ui', 'public'),
publicPath: '/',
filename: 'fredy.bundle.js',
},
performance: { hints: false },
module: {
rules: [
{
test: /\.js?$/,
exclude: /(node_modules|bower_components)/,
use: [{ loader: 'babel-loader' }],
},
{
test: /\.(css|less)$/i,
use: ['style-loader', 'css-loader', 'less-loader'],
},
{
test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
use: [{ loader: 'url-loader?limit=3000!image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false' }],
},
],
},
};

View File

@@ -1,26 +0,0 @@
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
const webpack = require('webpack');
const path = require('path');
module.exports = merge(common, {
devtool: 'inline-source-map',
devServer: {
static: path.join(__dirname, 'ui', 'public'),
port: 9000,
proxy: {
'/api': {
target: {
host: '0.0.0.0',
protocol: 'http:',
port: 9998,
},
},
},
},
plugins: [
new webpack.DefinePlugin({
__DEV__: JSON.stringify(true),
}),
],
});

View File

@@ -1,4 +0,0 @@
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
module.exports = merge(common, {});

1987
yarn.lock

File diff suppressed because it is too large Load Diff