diff --git a/examples/with-emotion/.babelrc b/examples/with-emotion/.babelrc new file mode 100644 index 000000000..625fc6a03 --- /dev/null +++ b/examples/with-emotion/.babelrc @@ -0,0 +1,11 @@ +{ + "presets": ["razzle/babel"], + "env": { + "production": { + "plugins": ["@emotion"] + }, + "development": { + "plugins": [["@emotion", { "sourceMap": true }]] + } + } +} \ No newline at end of file diff --git a/examples/with-emotion/.gitignore b/examples/with-emotion/.gitignore new file mode 100644 index 000000000..2b27d2abd --- /dev/null +++ b/examples/with-emotion/.gitignore @@ -0,0 +1,12 @@ +logs +*.log +npm-debug.log* +.DS_Store + +coverage +node_modules +build +.env.local +.env.development.local +.env.test.local +.env.production.local \ No newline at end of file diff --git a/examples/with-emotion/README.md b/examples/with-emotion/README.md new file mode 100644 index 000000000..29f72cd7c --- /dev/null +++ b/examples/with-emotion/README.md @@ -0,0 +1,24 @@ +# Razzle with-emotion Example + +## How to use +Download the example [or clone the whole project](https://github.com/jaredpalmer/razzle.git): + +```bash +curl https://codeload.github.com/jaredpalmer/razzle/tar.gz/master | tar -xz --strip=2 razzle-master/examples/with-emotion +cd with-emotion +``` + +Install it and run: + +```bash +yarn install +yarn start +``` + +## Idea behind the example +This is a basic, bare-bones example that shows a very minimal implementation +of [emotion 11](https://github.com/emotion-js/emotion). +It satisfies the entry points `src/index.js` for the server and`src/client.js` +for the browser. +There are comments in `src/server.js` to show how the styles are gathered and +rendered into to the DOM diff --git a/examples/with-emotion/package.json b/examples/with-emotion/package.json new file mode 100644 index 000000000..218f2bce0 --- /dev/null +++ b/examples/with-emotion/package.json @@ -0,0 +1,27 @@ +{ + "name": "razzle-examples-with-emotion", + "version": "0.1.0", + "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.15.2", + "react": "^16.13.0", + "react-dom": "^16.13.0", + "react-router": "^5.1.2", + "react-router-dom": "^5.1.2", + "@emotion/cache": "^11.0.0-next.10", + "@emotion/css": "^11.0.0-next.11", + "@emotion/react": "^11.0.0-next.11", + "@emotion/server": "^11.0.0-next.10", + "@emotion/styled": "^11.0.0-next.11" + }, + "devDependencies": { + "razzle": "^3.0.0", + "@emotion/babel-plugin": "^11.0.0-next.10" + } +} diff --git a/examples/with-emotion/public/favicon.ico b/examples/with-emotion/public/favicon.ico new file mode 100644 index 000000000..46bceb8c7 Binary files /dev/null and b/examples/with-emotion/public/favicon.ico differ diff --git a/examples/with-emotion/public/robots.txt b/examples/with-emotion/public/robots.txt new file mode 100644 index 000000000..54fb98911 --- /dev/null +++ b/examples/with-emotion/public/robots.txt @@ -0,0 +1,2 @@ +User-agent: * + diff --git a/examples/with-emotion/src/App.js b/examples/with-emotion/src/App.js new file mode 100644 index 000000000..d43c45245 --- /dev/null +++ b/examples/with-emotion/src/App.js @@ -0,0 +1,27 @@ +import React from 'react'; +import { Route, Switch, Link } from 'react-router-dom'; +import styled from '@emotion/styled'; +import { GreenPage } from './pages/green/green.page'; +import { HomePage } from './pages/home/home.page'; +import { Footer } from './components/footer'; +import { Header } from './components/header'; + +const Root = styled.div` + width: 980px; + margin: auto; +`; + +const App = () => ( + +
+
+ + + + +
+