Add npm and React boilerplate

This commit is contained in:
Lexi / Zoe 2022-05-20 00:00:59 +02:00
parent c60886b65e
commit 00d30ea36b
Signed by: binaryDiv
GPG Key ID: F8D4956E224DA232
9 changed files with 11849 additions and 131 deletions

139
.gitignore vendored
View File

@ -1,132 +1,13 @@
# ---> Node
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# IDEs / editors
.idea/
.vscode/
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# General
/tmp
/_tmp
.DS_STORE
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
# Node
.npm/
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional stylelint cache
.stylelintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# vuepress v2.x temp and cache directory
.temp
.cache
# Docusaurus cache and generated files
.docusaurus
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
dist/

View File

View File

@ -1,3 +1,3 @@
# tofu-ui
# Tofu - React UI
React frontend for Tofu - a to-do list app with a twist.
React frontend for Tofu - a to-do list app with a twist.

20
babel.config.json Normal file
View File

@ -0,0 +1,20 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"browsers": [
"last 2 versions",
"not op_mini all"
]
}
}
],
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-transform-runtime",
"babel-plugin-styled-components"
]
}

11709
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

40
package.json Normal file
View File

@ -0,0 +1,40 @@
{
"name": "tofu-ui",
"version": "0.0.1",
"description": "React frontend for Tofu - a to-do list app with a twist.",
"main": "dist/build.js",
"scripts": {
"build:dev": "rollup -c rollup.config.js",
"build:prod": "NODE_ENV=production rollup -c rollup.config.js",
"browse": "browser-sync start --s --ss build --index src/html/index.html --files dist/* --no-notify",
"start": "npm-run-all --parallel watch browse",
"watch": "rollup -c rollup.config.js -w",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git@git.0xbd.space:binaryDiv/tofu-ui.git"
},
"author": "binaryDiv",
"license": "BlueOak-1.0.0",
"devDependencies": {
"@babel/plugin-transform-runtime": "^7.16.4",
"@babel/preset-env": "^7.16.4",
"@babel/preset-react": "^7.16.0",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-node-resolve": "^13.1.1",
"@rollup/plugin-replace": "^3.0.0",
"babel-plugin-styled-components": "^2.0.2",
"browser-sync": "^2.27.7",
"npm-run-all": "^4.1.5",
"prop-types": "^15.8.1",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"rollup": "^2.58.0",
"rollup-plugin-node-globals": "^1.4.0",
"rollup-plugin-styles": "^4.0.0",
"rollup-plugin-terser": "^7.0.2",
"styled-components": "^5.3.3"
}
}

41
rollup.config.js Normal file
View File

@ -0,0 +1,41 @@
import commonjs from '@rollup/plugin-commonjs';
import nodeResolve from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import globals from 'rollup-plugin-node-globals';
import styles from 'rollup-plugin-styles';
import babel from '@rollup/plugin-babel';
const env = process.env.NODE_ENV;
const config = {
input: 'src/js/components/Root.js',
output: {
file: 'dist/build.js',
format: 'esm',
sourcemap: true,
name: 'Tofu',
inlineDynamicImports: true,
exports: 'auto',
},
plugins: [
styles(),
nodeResolve({
browser: true,
preferBuiltins: true,
extensions: ['.js', '.ts', '.tsx'],
}),
commonjs({
exclude: 'src/**',
}),
babel({
'babelHelpers': 'runtime',
}),
globals(),
replace({
'process.env.NODE_ENV': JSON.stringify(env === 'production' ? 'production' : 'development'),
'preventAssignment': true,
}),
],
};
export default config;

18
src/html/index.html Normal file
View File

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Tofu</title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
#root {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div id="root"></div>
<script src="dist/build.js" type="application/javascript"></script>
</body>
</html>

View File

@ -0,0 +1,9 @@
import React from "react";
import {createRoot} from "react-dom/client";
const Root = () => {
return <p>Meow world! :3</p>
};
const root = createRoot(document.getElementById('root'));
root.render(<Root/>);