Frontend CLI + Templates

This commit is contained in:
2024-03-25 17:03:46 +01:00
parent a54ab8620e
commit 716d623db4
10 changed files with 339 additions and 126 deletions

View File

@@ -0,0 +1,27 @@
const fs = require('fs');
const path = require('path');
const {
override,
removeModuleScopePlugin,
babelInclude,
addWebpackModuleRule,
} = require('customize-cra');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const addMiniCssExtractPlugin = config => {
config.plugins.push(new MiniCssExtractPlugin());
return config;
}
module.exports = override(
removeModuleScopePlugin(),
addMiniCssExtractPlugin,
addWebpackModuleRule({
test: /\.css$/,
use: [ MiniCssExtractPlugin.loader, 'css-loader' ]
}),
babelInclude([
path.resolve(path.join(__dirname, 'src')),
fs.realpathSync(path.join(__dirname, '../shared')),
]),
);

28
react/_tmpl/package.json Normal file
View File

@@ -0,0 +1,28 @@
{
"name": "{{MODULE_NAME}}",
"version": "1.0.0",
"dependencies": {
"shared": "link:../shared",
"react": "{{REACT_VERSION}}"
},
"scripts": {
"dev": "react-app-rewired start"
},
"author": "",
"license": "ISC",
"description": "",
"devDependencies": {},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"proxy": "http://localhost"
}

9
react/_tmpl/src/App.jsx Normal file
View File

@@ -0,0 +1,9 @@
import {useMemo} from "react";
import API from "shared/api";
export default function App() {
const api = useMemo(() => new API(), []);
return <></>
}

9
react/_tmpl/src/index.js Normal file
View File

@@ -0,0 +1,9 @@
import React from "react";
import {createRoot} from "react-dom/client";
import App from "./App";
import {LocaleProvider} from "shared/locale";
const root = createRoot(document.getElementById('{{MODULE_NAME}}'));
root.render(<LocaleProvider>
<App />
</LocaleProvider>);