Initial commit of create-razzle-app
This commit is contained in:
commit
502deb92d0
15 files changed
+8147
No files matched your search
+16
@@ -0,0 +1,16 @@
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
.DS_Store
|
||||
|
||||
coverage
|
||||
node_modules
|
||||
build
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
*.swp
|
||||
*.swo
|
||||
@@ -0,0 +1,262 @@
|
||||
**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).
|
||||
|
||||

|
||||
|
||||
[](https://circleci.com/gh/jaredpalmer/razzle/tree/master)  [](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`, `.eslintrc` and `razzle.config.js`
|
||||
* [Jest](https://github.com/facebook/jest) test runner setup with sensible defaults via `razzle test`
|
||||
|
||||
## Quick Start
|
||||
|
||||
[](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)
|
||||
* [Extending ESLint](#extending-eslint)
|
||||
* [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.
|
||||
|
||||
### Extending ESLint
|
||||
|
||||
Razzle comes with [Create React App's ESLint configuration](https://github.com/facebookincubator/create-react-app/tree/master/packages/eslint-config-react-app). Add a `.eslintrc` file to the root of your project to use your own configuration.
|
||||
|
||||
```js
|
||||
{
|
||||
"extends": "react-app",
|
||||
"rules": {
|
||||
// modify default rules
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 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`: Path to the public directory.
|
||||
* `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`: default is `3000`, unless changed
|
||||
* `process.env.HOST`: default is `0.0.0.0`
|
||||
* `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`.
|
||||
|
||||
You can create your own custom build-time environment variables. 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!
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "my-razzle-app",
|
||||
"version": "2.0.0-alpha.8",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"start": "razzle start",
|
||||
"build": "razzle build",
|
||||
"test": "razzle test --env=jsdom",
|
||||
"start:prod": "NODE_ENV=production node build/server.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"express": "^4.16.3",
|
||||
"razzle": "^2.2.0",
|
||||
"react": "^16.4.1",
|
||||
"react-dom": "^16.4.1",
|
||||
"react-router-dom": "^4.3.1"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
@@ -0,0 +1,2 @@
|
||||
User-agent: *
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import React from 'react';
|
||||
import Route from 'react-router-dom/Route';
|
||||
import Switch from 'react-router-dom/Switch';
|
||||
import Home from './Home';
|
||||
import './App.css';
|
||||
|
||||
const App = () => (
|
||||
<Switch>
|
||||
<Route exact path="/" component={Home} />
|
||||
</Switch>
|
||||
);
|
||||
|
||||
export default App;
|
||||
@@ -0,0 +1,16 @@
|
||||
import App from './App';
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import MemoryRouter from 'react-router-dom/MemoryRouter';
|
||||
|
||||
describe('<App />', () => {
|
||||
test('renders without exploding', () => {
|
||||
const div = document.createElement('div');
|
||||
ReactDOM.render(
|
||||
<MemoryRouter>
|
||||
<App />
|
||||
</MemoryRouter>,
|
||||
div
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,37 @@
|
||||
.Home {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.Home-logo {
|
||||
animation: Home-logo-spin infinite 20s linear;
|
||||
height: 80px;
|
||||
}
|
||||
|
||||
.Home-header {
|
||||
background-color: #222;
|
||||
height: 150px;
|
||||
padding: 20px;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.Home-intro {
|
||||
font-size: large;
|
||||
}
|
||||
|
||||
.Home-resources {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.Home-resources > li {
|
||||
display: inline-block;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
@keyframes Home-logo-spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
import React from 'react';
|
||||
import logo from './react.svg';
|
||||
import './Home.css';
|
||||
|
||||
class Home extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div className="Home">
|
||||
<div className="Home-header">
|
||||
<img src={logo} className="Home-logo" alt="logo" />
|
||||
<h2>Welcome to Razzle</h2>
|
||||
</div>
|
||||
<p className="Home-intro">
|
||||
To get started, edit <code>src/App.js</code> or{' '}
|
||||
<code>src/Home.js</code> and save to reload.
|
||||
</p>
|
||||
<ul className="Home-resources">
|
||||
<li>
|
||||
<a href="https://github.com/jaredpalmer/razzle">Docs</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/jaredpalmer/razzle/issues">Issues</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://palmer.chat">Community Slack</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Home;
|
||||
@@ -0,0 +1,15 @@
|
||||
import App from './App';
|
||||
import BrowserRouter from 'react-router-dom/BrowserRouter';
|
||||
import React from 'react';
|
||||
import { hydrate } from 'react-dom';
|
||||
|
||||
hydrate(
|
||||
<BrowserRouter>
|
||||
<App />
|
||||
</BrowserRouter>,
|
||||
document.getElementById('root')
|
||||
);
|
||||
|
||||
if (module.hot) {
|
||||
module.hot.accept();
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import app from './server';
|
||||
import http from 'http';
|
||||
|
||||
const server = http.createServer(app);
|
||||
|
||||
let currentApp = app;
|
||||
|
||||
server.listen(process.env.PORT || 3000, error => {
|
||||
if (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
console.log('🚀 started');
|
||||
});
|
||||
|
||||
if (module.hot) {
|
||||
console.log('✅ Server-side HMR Enabled!');
|
||||
|
||||
module.hot.accept('./server', () => {
|
||||
console.log('🔁 HMR Reloading `./server`...');
|
||||
server.removeListener('request', currentApp);
|
||||
const newApp = require('./server').default;
|
||||
server.on('request', newApp);
|
||||
currentApp = newApp;
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="256px" height="228px" viewBox="0 0 256 228" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid">
|
||||
<g>
|
||||
<path d="M210.483381,73.8236374 C207.827698,72.9095503 205.075867,72.0446761 202.24247,71.2267368 C202.708172,69.3261098 203.135596,67.4500894 203.515631,65.6059664 C209.753843,35.3248922 205.675082,10.9302478 191.747328,2.89849283 C178.392359,-4.80289661 156.551327,3.22703567 134.492936,22.4237776 C132.371761,24.2697233 130.244662,26.2241201 128.118477,28.2723861 C126.701777,26.917204 125.287358,25.6075897 123.876584,24.3549348 C100.758745,3.82852863 77.5866802,-4.82157937 63.6725966,3.23341515 C50.3303869,10.9571328 46.3792156,33.8904224 51.9945178,62.5880206 C52.5367729,65.3599011 53.1706189,68.1905639 53.8873982,71.068617 C50.6078941,71.9995641 47.4418534,72.9920277 44.4125156,74.0478303 C17.3093297,83.497195 0,98.3066828 0,113.667995 C0,129.533287 18.5815786,145.446423 46.8116526,155.095373 C49.0394553,155.856809 51.3511025,156.576778 53.7333796,157.260293 C52.9600965,160.37302 52.2875179,163.423318 51.7229345,166.398431 C46.3687351,194.597975 50.5500231,216.989464 63.8566899,224.664425 C77.6012619,232.590464 100.66852,224.443422 123.130185,204.809231 C124.905501,203.257196 126.687196,201.611293 128.472081,199.886102 C130.785552,202.113904 133.095375,204.222319 135.392897,206.199955 C157.14963,224.922338 178.637969,232.482469 191.932332,224.786092 C205.663234,216.837268 210.125675,192.78347 204.332202,163.5181 C203.88974,161.283006 203.374826,158.99961 202.796573,156.675661 C204.416503,156.196743 206.006814,155.702335 207.557482,155.188332 C236.905331,145.46465 256,129.745175 256,113.667995 C256,98.2510906 238.132466,83.3418093 210.483381,73.8236374 L210.483381,73.8236374 Z M204.118035,144.807565 C202.718197,145.270987 201.281904,145.718918 199.818271,146.153177 C196.578411,135.896354 192.205739,124.989735 186.854729,113.72131 C191.961041,102.721277 196.164656,91.9540963 199.313837,81.7638014 C201.93261,82.5215915 204.474374,83.3208483 206.923636,84.1643056 C230.613348,92.3195488 245.063763,104.377206 245.063763,113.667995 C245.063763,123.564379 229.457753,136.411268 204.118035,144.807565 L204.118035,144.807565 Z M193.603754,165.642007 C196.165567,178.582766 196.531475,190.282717 194.834536,199.429057 C193.309843,207.64764 190.243595,213.12715 186.452366,215.321689 C178.384612,219.991462 161.131788,213.921395 142.525146,197.909832 C140.392124,196.074366 138.243609,194.114502 136.088259,192.040261 C143.301619,184.151133 150.510878,174.979732 157.54698,164.793993 C169.922699,163.695814 181.614905,161.900447 192.218042,159.449363 C192.740247,161.555956 193.204126,163.621993 193.603754,165.642007 L193.603754,165.642007 Z M87.2761866,214.514686 C79.3938934,217.298414 73.1160375,217.378157 69.3211631,215.189998 C61.2461189,210.532528 57.8891498,192.554265 62.4682434,168.438039 C62.9927272,165.676183 63.6170041,162.839142 64.3365173,159.939216 C74.8234575,162.258154 86.4299951,163.926841 98.8353334,164.932519 C105.918826,174.899534 113.336329,184.06091 120.811247,192.08264 C119.178102,193.65928 117.551336,195.16028 115.933685,196.574699 C106.001303,205.256705 96.0479605,211.41654 87.2761866,214.514686 L87.2761866,214.514686 Z M50.3486141,144.746959 C37.8658105,140.48046 27.5570398,134.935332 20.4908634,128.884403 C14.1414664,123.446815 10.9357817,118.048415 10.9357817,113.667995 C10.9357817,104.34622 24.8334611,92.4562517 48.0123604,84.3748281 C50.8247961,83.3942121 53.7689223,82.4701001 56.8242337,81.6020363 C60.0276398,92.0224477 64.229889,102.917218 69.3011135,113.93411 C64.1642716,125.11459 59.9023288,136.182975 56.6674809,146.725506 C54.489347,146.099407 52.3791089,145.440499 50.3486141,144.746959 L50.3486141,144.746959 Z M62.7270678,60.4878073 C57.9160346,35.9004118 61.1112387,17.3525532 69.1516515,12.6982729 C77.7160924,7.74005624 96.6544653,14.8094222 116.614922,32.5329619 C117.890816,33.6657739 119.171723,34.8514442 120.456275,36.0781256 C113.018267,44.0647686 105.66866,53.1573386 98.6480514,63.0655695 C86.6081646,64.1815215 75.0831931,65.9741531 64.4868907,68.3746571 C63.8206914,65.6948233 63.2305903,63.0619242 62.7270678,60.4878073 L62.7270678,60.4878073 Z M173.153901,87.7550367 C170.620796,83.3796304 168.020249,79.1076627 165.369124,74.9523483 C173.537126,75.9849113 181.362914,77.3555864 188.712066,79.0329319 C186.505679,86.1041206 183.755673,93.4974728 180.518546,101.076741 C178.196419,96.6680702 175.740322,92.2229454 173.153901,87.7550367 L173.153901,87.7550367 Z M128.122121,43.8938899 C133.166461,49.3588189 138.218091,55.4603279 143.186789,62.0803968 C138.179814,61.8439007 133.110868,61.720868 128.000001,61.720868 C122.937434,61.720868 117.905854,61.8411667 112.929865,62.0735617 C117.903575,55.515009 122.99895,49.4217021 128.122121,43.8938899 L128.122121,43.8938899 Z M82.8018984,87.830679 C80.2715265,92.2183886 77.8609975,96.6393627 75.5753239,101.068539 C72.3906004,93.5156998 69.6661103,86.0886276 67.440586,78.9171899 C74.7446255,77.2826781 82.5335049,75.9461789 90.6495601,74.9332099 C87.9610684,79.1268011 85.3391054,83.4302106 82.8018984,87.8297677 L82.8018984,87.830679 L82.8018984,8Line truncated
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 7.7 KiB |
@@ -0,0 +1,51 @@
|
||||
import App from './App';
|
||||
import React from 'react';
|
||||
import { StaticRouter } from 'react-router-dom';
|
||||
import express from 'express';
|
||||
import { renderToString } from 'react-dom/server';
|
||||
|
||||
const assets = require(process.env.RAZZLE_ASSETS_MANIFEST);
|
||||
|
||||
const server = express();
|
||||
server
|
||||
.disable('x-powered-by')
|
||||
.use(express.static(process.env.RAZZLE_PUBLIC_DIR))
|
||||
.get('/*', (req, res) => {
|
||||
const context = {};
|
||||
const markup = renderToString(
|
||||
<StaticRouter context={context} location={req.url}>
|
||||
<App />
|
||||
</StaticRouter>
|
||||
);
|
||||
|
||||
if (context.url) {
|
||||
res.redirect(context.url);
|
||||
} else {
|
||||
res.status(200).send(
|
||||
`<!doctype html>
|
||||
<html lang="">
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta charset="utf-8" />
|
||||
<title>Welcome to Razzle</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
${
|
||||
assets.client.css
|
||||
? `<link rel="stylesheet" href="${assets.client.css}">`
|
||||
: ''
|
||||
}
|
||||
${
|
||||
process.env.NODE_ENV === 'production'
|
||||
? `<script src="${assets.client.js}" defer></script>`
|
||||
: `<script src="${assets.client.js}" defer crossorigin></script>`
|
||||
}
|
||||
</head>
|
||||
<body>
|
||||
<div id="root">${markup}</div>
|
||||
</body>
|
||||
</html>`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
export default server;
|
||||
Reference in new issue
Block a user