mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
feat: initial commit
This commit is contained in:
parent
92c706ae98
commit
04e2d22cf8
19 changed files with 12238 additions and 0 deletions
1
packages/ui/.eslintignore
Normal file
1
packages/ui/.eslintignore
Normal file
|
@ -0,0 +1 @@
|
|||
razzle.config.js
|
25
packages/ui/.gitignore
vendored
Normal file
25
packages/ui/.gitignore
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
/build
|
||||
/lib
|
||||
|
||||
# logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# misc
|
||||
cache
|
||||
.DS_Store
|
||||
*.env
|
249
packages/ui/README.md
Normal file
249
packages/ui/README.md
Normal file
|
@ -0,0 +1,249 @@
|
|||
**WARNING: This is the documentation for `razzle@next` (Webpack 4).**
|
||||
[Go here for for razzle@0.8.x (stable) docs (Webpack 3)](https://github.com/jaredpalmer/razzle/tree/master).
|
||||
|
||||
![repo-banner](https://user-images.githubusercontent.com/4060187/28923990-050a32d4-782e-11e7-9da7-574ce5a8b455.png)
|
||||
|
||||
[![CircleCI](https://circleci.com/gh/jaredpalmer/razzle/tree/master.svg?style=shield)](https://circleci.com/gh/jaredpalmer/razzle/tree/master) ![Razzle-status](https://david-dm.org/jaredpalmer/razzle.svg?path=packages/razzle) [![npm version](https://badge.fury.io/js/razzle.svg)](https://badge.fury.io/js/razzle)
|
||||
|
||||
Universal JavaScript applications are tough to setup. Either you buy into a framework like [Next.js](https://github.com/zeit/next.js) or [react-server](https://github.com/redfin/react-server), fork a boilerplate, or set things up yourself. Aiming to fill this void, Razzle is a tool that abstracts all complex configuration needed for SSR into a single dependency--giving you the awesome developer experience of [create-react-app](https://github.com/facebookincubator/create-react-app), but then leaving the rest of your app's architectural decisions about frameworks, routing, and data fetching up to you. With this approach, Razzle not only works with React, but also Reason, Elm, Vue, Angular, and most importantly......whatever comes next.
|
||||
|
||||
**Razzle comes with the "battery-pack included"**:
|
||||
|
||||
* :fire: Universal Hot Module Replacement, so both the client and server update whenever you make edits. No annoying restarts necessary
|
||||
* Comes with your favorite ES6 JavaScript goodies (through `babel-preset-razzle`)
|
||||
* Comes with the same CSS setup as [create-react-app](https://github.com/facebookincubator/create-react-app)
|
||||
* Works with [React](https://github.com/facebook/react), [Preact](https://github.com/developit/preact), [Elm](http://elm-lang.org/), [Reason-React](https://github.com/jaredpalmer/razzle/tree/master/examples/with-reason-react), [Inferno](https://github.com/infernojs), and [Rax](https://github.com/alibaba/rax) as well as [Angular](https://github.com/angular/angular) and [Vue](https://github.com/vuejs/vue) if that's your thing
|
||||
* Escape hatches for customization via `.babelrc` and `razzle.config.js`
|
||||
* [Jest](https://github.com/facebook/jest) test runner setup with sensible defaults via `razzle test`
|
||||
|
||||
## Quick Start
|
||||
|
||||
[![Greenkeeper badge](https://badges.greenkeeper.io/jaredpalmer/razzle.svg)](https://greenkeeper.io/)
|
||||
|
||||
```bash
|
||||
npm install -g create-razzle-app
|
||||
|
||||
create-razzle-app my-app
|
||||
cd my-app
|
||||
npm start
|
||||
```
|
||||
|
||||
Then open http://localhost:3000/ to see your app. Your console should look like this:
|
||||
|
||||
<img src="https://cloud.githubusercontent.com/assets/4060187/26324663/b31788c4-3f01-11e7-8e6f-ffa48533af54.png" width="500px" alt="Razzle Development Mode"/>
|
||||
|
||||
**That's it**. You don't need to worry about setting up multiple webpack configs or other build tools. Just start editing `src/App.js` and go!
|
||||
|
||||
Below is a list of commands you will probably find useful.
|
||||
|
||||
### `npm start` or `yarn start`
|
||||
|
||||
Runs the project in development mode.
|
||||
You can view your application at `http://localhost:3000`
|
||||
|
||||
The page will reload if you make edits.
|
||||
|
||||
### `npm run build` or `yarn build`
|
||||
|
||||
Builds the app for production to the build folder.
|
||||
|
||||
The build is minified and the filenames include the hashes.
|
||||
Your app is ready to be deployed!
|
||||
|
||||
### `npm run start:prod` or `yarn start:prod`
|
||||
|
||||
Runs the compiled app in production.
|
||||
|
||||
You can again view your application at `http://localhost:3000`
|
||||
|
||||
### `npm test` or `yarn test`
|
||||
|
||||
Runs the test watcher (Jest) in an interactive mode.
|
||||
By default, runs tests related to files changed since the last commit.
|
||||
|
||||
### `npm start -- --inspect` or `yarn start -- --inspect`
|
||||
|
||||
To debug the node server, you can use `razzle start --inspect`. This will start the node server and enable the inspector agent. For more information, see [this](https://nodejs.org/en/docs/inspector/).
|
||||
|
||||
### `npm start -- --inspect-brk` or `yarn start -- --inspect-brk`
|
||||
|
||||
To debug the node server, you can use `razzle start --inspect-brk`. This will start the node server, enable the inspector agent and Break before user code starts. For more information, see [this](https://nodejs.org/en/docs/inspector/).
|
||||
|
||||
### `rs`
|
||||
|
||||
If your application is running, and you need to manually restart your server, you do not need to completely kill and rebundle your application. Instead you can just type `rs` and press enter in terminal.
|
||||
|
||||
## <img src="https://user-images.githubusercontent.com/4060187/37915268-209644d0-30e7-11e8-8ef7-086b529ede8c.png" width="500px" alt="Razzle Hot Restart"/>
|
||||
|
||||
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
||||
|
||||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
||||
|
||||
**Table of Contents**
|
||||
|
||||
* [Customization](#customization)
|
||||
* [Extending Babel Config](#extending-babel-config)
|
||||
* [Extending Webpack](#extending-webpack)
|
||||
* [Environment Variables](#environment-variables)
|
||||
* [Adding Temporary Environment Variables In Your Shell](#adding-temporary-environment-variables-in-your-shell)
|
||||
* [Windows (cmd.exe)](#windows-cmdexe)
|
||||
* [Linux, macOS (Bash)](#linux-macos-bash)
|
||||
* [Adding Environment Variables In `.env`](#adding-environment-variables-in-env)
|
||||
* [What other `.env` files are can be used?](#what-other-env-files-are-can-be-used)
|
||||
* [How Razzle works (the secret sauce)](#how-razzle-works-the-secret-sauce)
|
||||
* [Inspiration](#inspiration)
|
||||
* [Author](#author)
|
||||
* [Contributors](#contributors)
|
||||
|
||||
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
||||
|
||||
## Customization
|
||||
|
||||
### Customizing Babel Config
|
||||
|
||||
Razzle comes with most of ES6 stuff you need. However, if you want to add your own babel transformations, just add a `.babelrc` file to the root of your project.
|
||||
|
||||
```js
|
||||
{
|
||||
"presets": [
|
||||
"razzle/babel", // NEEDED
|
||||
"stage-0"
|
||||
],
|
||||
"plugins": [
|
||||
// additional plugins
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
A word of advice: the `.babelrc` file will replace the internal razzle babelrc template. You must include at the very minimum the default razzle/babel preset.
|
||||
|
||||
### Extending Webpack
|
||||
|
||||
You can also extend the underlying webpack config. Create a file called `razzle.config.js` in your project's root.
|
||||
|
||||
```js
|
||||
// razzle.config.js
|
||||
|
||||
module.exports = {
|
||||
modify: (config, { target, dev }, webpack) => {
|
||||
// do something to config
|
||||
|
||||
return config;
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
A word of advice: `razzle.config.js` is an escape hatch. However, since it's just JavaScript, you can and should publish your `modify` function to npm to make it reusable across your projects. For example, imagine you added some custom webpack loaders and published it as a package to npm as `my-razzle-modifictions`. You could then write your `razzle.config.js` like so:
|
||||
|
||||
```
|
||||
// razzle.config.js
|
||||
const modify = require('my-razzle-modifictions');
|
||||
|
||||
module.exports = {
|
||||
modify
|
||||
}
|
||||
```
|
||||
|
||||
Last but not least, if you find yourself needing a more customized setup, Razzle is _very_ forkable. There is one webpack configuration factory that is 300 lines of code, and 4 scripts (`build`, `start`, `test`, and `init`). The paths setup is shamelessly taken from [create-react-app](https://github.com/facebookincubator/create-react-app), and the rest of the code related to logging.
|
||||
|
||||
### Environment Variables
|
||||
|
||||
**The environment variables are embedded during the build time.** You can read them at runtime just because by default we export them with the `webpack.DefinePlugin`.
|
||||
|
||||
* `process.env.RAZZLE_PUBLIC_DIR`: Absolute path to the public directory in the server's filesystem.
|
||||
* `process.env.RAZZLE_ASSETS_MANIFEST`: Path to a file containing compiled asset outputs
|
||||
* `process.env.REACT_BUNDLE_PATH`: Relative path to where React will be bundled during development. Unless you are modifying the output path of your webpack config, you can safely ignore this. This path is used by `react-error-overlay` and webpack to power up the fancy runtime error iframe. For example, if you are using common chunks and an extra entry to create a vendor bundle with stuff like react, react-dom, react-router, etc. called `vendor.js`, and you've changed webpack's output to `[name].js` in development, you'd want to set this environment variable to `/static/js/vendor.js`. If you do not make this change, nothing bad will happen, you will simply not get the cool error overlay when there are runtime errors. You'll just see them in the console. Note: This does not impact production bundling.
|
||||
* `process.env.VERBOSE`: default is false, setting this to true will not clear the console when you make edits in development (useful for debugging).
|
||||
* `process.env.PORT`: The `BUILD_TARGET=server` build listens on this port for all NODE_ENVs. default is `3000`
|
||||
* `process.env.HOST`: The IP address that the server will bind to. default is `0.0.0.0`, for INADDR_ANY
|
||||
* `process.env.NODE_ENV`: `'development'` or `'production'`
|
||||
* `process.env.BUILD_TARGET`: either `'client'` or `'server'`
|
||||
* `process.env.PUBLIC_PATH`: Only in used in `razzle build`. You can alter the `webpack.config.output.publicPath` of the client assets (bundle, css, and images). This is useful if you plan to serve your assets from a CDN. Make sure to _include_ a trailing slash (e.g. `PUBLIC_PATH=https://cdn.example.com/`). If you are using React and altering the public path, make sure to also [include the `crossorigin` attribute](https://reactjs.org/docs/installation.html#using-a-cdn) on your `<script>` tag in `src/server.js`.
|
||||
* `process.env.CLIENT_PUBLIC_PATH`: The `NODE_ENV=development` build's `BUILD_TARGET=client` has a different `PUBLIC_PATH` than `BUILD_TARGET=server`. Default is `http://${process.env.HOST}:${process.env.PORT + 1}/`
|
||||
|
||||
You can create your own custom environment variables that will be inlined during the build. They must start
|
||||
with `RAZZLE_`. Any other variables except the ones listed above will be ignored to avoid accidentally exposing a private key on the machine that could have the same name. Changing any environment variables will require you to restart the development server if it is running.
|
||||
|
||||
These environment variables will be defined for you on `process.env`. For example, having an environment variable named `RAZZLE_SECRET_CODE` will be exposed in your JS as `process.env.RAZZLE_SECRET_CODE`.
|
||||
|
||||
### Adding Temporary Environment Variables In Your Shell
|
||||
|
||||
Defining environment variables can vary between OSes. It’s also important to know that this manner is temporary for the
|
||||
life of the shell session.
|
||||
|
||||
#### Windows (cmd.exe)
|
||||
|
||||
```cmd
|
||||
set RAZZLE_SECRET_CODE=abcdef&&npm start
|
||||
```
|
||||
|
||||
(Note: the lack of whitespace is intentional.)
|
||||
|
||||
#### Linux, macOS (Bash)
|
||||
|
||||
```bash
|
||||
RAZZLE_SECRET_CODE=abcdef npm start
|
||||
```
|
||||
|
||||
### Adding Environment Variables In `.env`
|
||||
|
||||
To define permanent environment variables, create a file called .env in the root of your project:
|
||||
|
||||
```
|
||||
RAZZLE_SECRET_CODE=abcdef
|
||||
```
|
||||
|
||||
#### What other `.env` files are can be used?
|
||||
|
||||
* `.env`: Default.
|
||||
* `.env.local`: Local overrides. **This file is loaded for all environments except test.**
|
||||
* `.env.development`, `.env.test`, `.env.production`: Environment-specific settings.
|
||||
* `.env.development.local`, `.env.test.local`, `.env.production.local`: Local overrides of environment-specific settings.
|
||||
|
||||
Files on the left have more priority than files on the right:
|
||||
|
||||
* `npm start`: `.env.development.local`, `.env.development`, `.env.local`, `.env`
|
||||
* `npm run build`: `.env.production.local`, `.env.production`, `.env.local`, `.env`
|
||||
* `npm test`: `.env.test.local`, `.env.test`, `.env` (note `.env.local` is missing)
|
||||
|
||||
These variables will act as the defaults if the machine does not explicitly set them.<br>
|
||||
Please refer to the [dotenv documentation](https://github.com/motdotla/dotenv) for more details.
|
||||
|
||||
> Note: If you are defining environment variables for development, your CI and/or hosting platform will most likely need
|
||||
> these defined as well. Consult their documentation how to do this. For example, see the documentation for [Travis CI](https://docs.travis-ci.com/user/environment-variables/) or [Heroku](https://devcenter.heroku.com/articles/config-vars).
|
||||
|
||||
## How Razzle works (the secret sauce)
|
||||
|
||||
**tl;dr**: 2 configs, 2 ports, 2 webpack instances, both watching and hot reloading the same filesystem, in parallel during development and a little `webpack.output.publicPath` magic.
|
||||
|
||||
In development mode (`razzle start`), Razzle bundles both your client and server code using two different webpack instances running with Hot Module Replacement in parallel. While your server is bundled and run on whatever port your specify in `src/index.js` (`3000` is the default), the client bundle (i.e. entry point at `src/client.js`) is served via `webpack-dev-server` on a different port (`3001` by default) with its `publicPath` explicitly set to `localhost:3001` (and not `/` like many other setups do). Then the server's html template just points to the absolute url of the client JS: `localhost:3001/static/js/client.js`. Since both webpack instances watch the same files, whenever you make edits, they hot reload at _exactly_ the same time. Best of all, because they use the same code, the same webpack loaders, and the same babel transformations, you never run into a React checksum mismatch error.
|
||||
|
||||
## Inspiration
|
||||
|
||||
* [palmerhq/backpack](https://github.com/palmerhq/backpack)
|
||||
* [nytimes/kyt](https://github.com/nytimes/kyt)
|
||||
* [facebookincubator/create-react-app](https://github.com/facebookincubator/create-react-app)
|
||||
* [humblespark/sambell](https://github.com/humblespark/sambell)
|
||||
* [zeit/next.js](https://github.com/zeit/next.js)
|
||||
|
||||
#### Author
|
||||
|
||||
* [Jared Palmer](https://twitter.com/jaredpalmer)
|
||||
|
||||
---
|
||||
|
||||
MIT License
|
||||
|
||||
## Contributors
|
||||
|
||||
Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):
|
||||
|
||||
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
||||
|
||||
| [<img src="https://avatars2.githubusercontent.com/u/4060187?v=4" width="100px;"/><br /><sub>Jared Palmer</sub>](http://jaredpalmer.com)<br />[💬](#question-jaredpalmer 'Answering Questions') [💻](https://github.com/jaredpalmer/razzle/commits?author=jaredpalmer 'Code') [🎨](#design-jaredpalmer 'Design') [📖](https://github.com/jaredpalmer/razzle/commits?author=jaredpalmer 'Documentation') [💡](#example-jaredpalmer 'Examples') [🤔](#ideas-jaredpalmer 'Ideas, Planning, & Feedback') [👀](#review-jaredpalmer 'Reviewed Pull Requests') [⚠️](https://github.com/jaredpalmer/razzle/commits?author=jaredpalmer 'Tests') [🔧](#tool-jaredpalmer 'Tools') | [<img src="https://avatars3.githubusercontent.com/u/1415847?v=4" width="100px;"/><br /><sub>Jari Zwarts</sub>](https://jari.io)<br />[💬](#question-jariz 'Answering Questions') [💻](https://github.com/jaredpalmer/razzle/commits?author=jariz 'Code') [🤔](#ideas-jariz 'Ideas, Planning, & Feedback') [🔌](#plugin-jariz 'Plugin/utility libraries') [👀](#review-jariz 'Reviewed Pull Requests') | [<img src="https://avatars0.githubusercontent.com/u/810438?v=4" width="100px;"/><br /><sub>Dan Abramov</sub>](http://twitter.com/dan_abramov)<br />[💻](https://github.com/jaredpalmer/razzle/commits?author=gaearon 'Code') [🤔](#ideas-gaearon 'Ideas, Planning, & Feedback') | [<img src="https://avatars0.githubusercontent.com/u/15182?v=4" width="100px;"/><br /><sub>Eric Clemmons</sub>](http://ericclemmons.github.com/)<br />[💻](https://github.com/jaredpalmer/razzle/commits?author=ericclemmons 'Code') [🤔](#ideas-ericclemmons 'Ideas, Planning, & Feedback') |
|
||||
| :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|
||||
|
||||
|
||||
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
||||
|
||||
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!
|
64
packages/ui/package.json
Normal file
64
packages/ui/package.json
Normal file
|
@ -0,0 +1,64 @@
|
|||
{
|
||||
"name": "react-boilerplate",
|
||||
"version": "0.1.0",
|
||||
"license": "UNLICENSED",
|
||||
"scripts": {
|
||||
"start": "razzle start",
|
||||
"start:prod": "NODE_ENV=production node build/server.js",
|
||||
"build": "razzle build",
|
||||
"lint": "eslint --format pretty --ext .ts --ext .tsx src",
|
||||
"stylelint": "stylelint \"src/**/*.scss\"",
|
||||
"test": "razzle test --env=jsdom",
|
||||
"prepare": "husky install"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-router-dom": "^5.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.14.6",
|
||||
"@commitlint/cli": "^12.1.4",
|
||||
"@commitlint/config-conventional": "^12.1.4",
|
||||
"@logto/eslint-config": "^0.1.0-rc.6",
|
||||
"@logto/eslint-config-react": "^0.1.0-rc.7",
|
||||
"@logto/ts-config": "^0.1.0-rc.6",
|
||||
"@logto/ts-config-react": "^0.1.0-rc.7",
|
||||
"@types/jest": "^26.0.24",
|
||||
"@types/react": "^17.0.14",
|
||||
"@types/react-dom": "^17.0.9",
|
||||
"@types/react-router-dom": "^5.1.8",
|
||||
"@types/webpack-env": "^1.16.2",
|
||||
"babel-preset-razzle": "4.0.5",
|
||||
"eslint": "^7.30.0",
|
||||
"eslint-formatter-pretty": "^4.1.0",
|
||||
"html-webpack-plugin": "^4.5.2",
|
||||
"husky": "^7.0.1",
|
||||
"lint-staged": ">=10",
|
||||
"mini-css-extract-plugin": "^0.9.0",
|
||||
"prettier": "^2.3.2",
|
||||
"razzle": "^4.0.5",
|
||||
"razzle-dev-utils": "^4.0.5",
|
||||
"razzle-plugin-scss": "^4.0.5",
|
||||
"stylelint": "^13.13.1",
|
||||
"typescript": "^4.3.5",
|
||||
"webpack": "^4.44.1",
|
||||
"webpack-dev-server": "^3.11.2"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "@logto/react"
|
||||
},
|
||||
"stylelint": {
|
||||
"extends": "@logto/eslint-config-react/.stylelintrc"
|
||||
},
|
||||
"prettier": "@logto/eslint-config/.prettierrc",
|
||||
"commitlint": {
|
||||
"extends": [
|
||||
"@commitlint/config-conventional"
|
||||
]
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{ts,tsx}": "eslint --cache --fix",
|
||||
"*.scss": "stylelint --fix"
|
||||
}
|
||||
}
|
BIN
packages/ui/public/favicon.ico
Normal file
BIN
packages/ui/public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
32
packages/ui/public/index.html
Normal file
32
packages/ui/public/index.html
Normal file
|
@ -0,0 +1,32 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="<%= process.env.PUBLIC_PATH %>favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<%= htmlWebpackPlugin.tags.headTags %>
|
||||
<!--
|
||||
Notice the use of <%= process.env.PUBLIC_PATH %> in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
Only files inside the `public` folder can be referenced from the HTML.
|
||||
Unlike "/favicon.ico" or "favicon.ico", "<%= process.env.PUBLIC_PATH %>/favicon.ico" will
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<title>React App</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
<%= htmlWebpackPlugin.tags.bodyTags %>
|
||||
</body>
|
||||
</html>
|
2
packages/ui/public/robots.txt
Normal file
2
packages/ui/public/robots.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
User-agent: *
|
||||
|
19
packages/ui/razzle.config.js
Normal file
19
packages/ui/razzle.config.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
"use strict";
|
||||
|
||||
const path = require("path");
|
||||
|
||||
module.exports = {
|
||||
options: {
|
||||
buildType: "spa",
|
||||
},
|
||||
plugins: ["scss"],
|
||||
modifyWebpackConfig: ({ webpackConfig }) => {
|
||||
const config = { ...webpackConfig };
|
||||
|
||||
config.resolve.alias = {
|
||||
"@": path.resolve("src/"),
|
||||
};
|
||||
|
||||
return config;
|
||||
},
|
||||
};
|
5
packages/ui/sandbox.config.json
Normal file
5
packages/ui/sandbox.config.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"container": {
|
||||
"port": 3000
|
||||
}
|
||||
}
|
16
packages/ui/src/App.test.tsx
Normal file
16
packages/ui/src/App.test.tsx
Normal file
|
@ -0,0 +1,16 @@
|
|||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
import App from './App';
|
||||
|
||||
describe('<App />', () => {
|
||||
test('renders without exploding', () => {
|
||||
const div = document.createElement('div');
|
||||
ReactDOM.render(
|
||||
<MemoryRouter>
|
||||
<App />
|
||||
</MemoryRouter>,
|
||||
div
|
||||
);
|
||||
});
|
||||
});
|
11
packages/ui/src/App.tsx
Normal file
11
packages/ui/src/App.tsx
Normal file
|
@ -0,0 +1,11 @@
|
|||
import React from 'react';
|
||||
import { Route, Switch } from 'react-router-dom';
|
||||
import Home from './pages/Home';
|
||||
|
||||
const App = () => (
|
||||
<Switch>
|
||||
<Route exact path="/" component={Home} />
|
||||
</Switch>
|
||||
);
|
||||
|
||||
export default App;
|
18
packages/ui/src/client.tsx
Normal file
18
packages/ui/src/client.tsx
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* eslint-disable unicorn/prefer-module */
|
||||
import { BrowserRouter } from 'react-router-dom';
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import App from './App';
|
||||
|
||||
const render = module.hot ? ReactDOM.render : ReactDOM.hydrate;
|
||||
|
||||
render(
|
||||
<BrowserRouter>
|
||||
<App />
|
||||
</BrowserRouter>,
|
||||
document.querySelector('#root')
|
||||
);
|
||||
|
||||
if (module.hot) {
|
||||
module.hot.accept();
|
||||
}
|
62
packages/ui/src/include.d/react-app.d.ts
vendored
Normal file
62
packages/ui/src/include.d/react-app.d.ts
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
// Copied from react-scripts/lib/react-app.d.ts
|
||||
|
||||
declare module '*.avif' {
|
||||
const src: string;
|
||||
export default src;
|
||||
}
|
||||
|
||||
declare module '*.bmp' {
|
||||
const src: string;
|
||||
export default src;
|
||||
}
|
||||
|
||||
declare module '*.gif' {
|
||||
const src: string;
|
||||
export default src;
|
||||
}
|
||||
|
||||
declare module '*.jpg' {
|
||||
const src: string;
|
||||
export default src;
|
||||
}
|
||||
|
||||
declare module '*.jpeg' {
|
||||
const src: string;
|
||||
export default src;
|
||||
}
|
||||
|
||||
declare module '*.png' {
|
||||
const src: string;
|
||||
export default src;
|
||||
}
|
||||
|
||||
declare module '*.webp' {
|
||||
const src: string;
|
||||
export default src;
|
||||
}
|
||||
|
||||
declare module '*.svg' {
|
||||
import * as React from 'react';
|
||||
|
||||
export const ReactComponent: React.FunctionComponent<
|
||||
React.SVGProps<SVGSVGElement> & { title?: string }
|
||||
>;
|
||||
|
||||
const src: string;
|
||||
export default src;
|
||||
}
|
||||
|
||||
declare module '*.module.css' {
|
||||
const classes: Readonly<Record<string, string>>;
|
||||
export default classes;
|
||||
}
|
||||
|
||||
declare module '*.module.scss' {
|
||||
const classes: Readonly<Record<string, string>>;
|
||||
export default classes;
|
||||
}
|
||||
|
||||
declare module '*.module.sass' {
|
||||
const classes: Readonly<Record<string, string>>;
|
||||
export default classes;
|
||||
}
|
5
packages/ui/src/pages/Home/index.module.scss
Normal file
5
packages/ui/src/pages/Home/index.module.scss
Normal file
|
@ -0,0 +1,5 @@
|
|||
@use '@/scss/underscore' as _;
|
||||
|
||||
.wrapper {
|
||||
padding: _.unit(5);
|
||||
}
|
8
packages/ui/src/pages/Home/index.tsx
Normal file
8
packages/ui/src/pages/Home/index.tsx
Normal file
|
@ -0,0 +1,8 @@
|
|||
import React from 'react';
|
||||
import styles from './index.module.scss';
|
||||
|
||||
const Home = () => {
|
||||
return <div className={styles.wrapper}>Hello, world!</div>;
|
||||
};
|
||||
|
||||
export default Home;
|
3
packages/ui/src/scss/_underscore.scss
Normal file
3
packages/ui/src/scss/_underscore.scss
Normal file
|
@ -0,0 +1,3 @@
|
|||
@function unit($factor, $unit: 'px') {
|
||||
@return #{$factor * 4}#{$unit};
|
||||
}
|
8
packages/ui/src/scss/normalized.scss
Normal file
8
packages/ui/src/scss/normalized.scss
Normal file
|
@ -0,0 +1,8 @@
|
|||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: sans-serif;
|
||||
background: #101419;
|
||||
color: #dadae0;
|
||||
text-align: center;
|
||||
}
|
13
packages/ui/tsconfig.json
Normal file
13
packages/ui/tsconfig.json
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"extends": "@logto/ts-config-react/tsconfig.base",
|
||||
"compilerOptions": {
|
||||
"paths": {
|
||||
"@/*": [
|
||||
"./src/*"
|
||||
]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
]
|
||||
}
|
11697
packages/ui/yarn.lock
Normal file
11697
packages/ui/yarn.lock
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue