From 580e574c841fb9b0ba9d37a50bd5a0f787799ff2 Mon Sep 17 00:00:00 2001 From: August Skare Date: Fri, 19 Oct 2018 15:02:15 +0100 Subject: Feature/build step (#2) * BundleAnalyzerPlugin * lazy load highlight.js * seperate bundles for each page * prerender apps to html on build * preload important font files * dont prerender code copy button * fix woff2 variant of font * added missing doctype * remove metatags component --- packages/dev-tools-pages/.gitignore | 3 +- packages/dev-tools-pages/assets/crawl.html | 20 ++++++ .../dev-tools-pages/assets/favicons/compiler.ico | Bin 0 -> 6518 bytes packages/dev-tools-pages/assets/favicons/cov.ico | Bin 0 -> 6518 bytes .../dev-tools-pages/assets/favicons/profiler.ico | Bin 0 -> 6518 bytes packages/dev-tools-pages/assets/favicons/trace.ico | Bin 0 -> 6518 bytes packages/dev-tools-pages/assets/index.html | 14 ++++ packages/dev-tools-pages/package.json | 12 +++- packages/dev-tools-pages/pages.js | 72 +++++++++++++++++++++ .../dev-tools-pages/public/favicons/compiler.ico | Bin 6518 -> 0 bytes packages/dev-tools-pages/public/favicons/cov.ico | Bin 6518 -> 0 bytes .../dev-tools-pages/public/favicons/profiler.ico | Bin 6518 -> 0 bytes packages/dev-tools-pages/public/favicons/trace.ico | Bin 6518 -> 0 bytes packages/dev-tools-pages/public/index.html | 15 ----- packages/dev-tools-pages/ts/components/Base.tsx | 26 ++++++++ packages/dev-tools-pages/ts/components/Code.tsx | 6 +- .../dev-tools-pages/ts/components/MetaTags.tsx | 28 -------- packages/dev-tools-pages/ts/globalStyles.tsx | 6 +- packages/dev-tools-pages/ts/globals.d.ts | 2 + packages/dev-tools-pages/ts/highlight.tsx | 6 ++ packages/dev-tools-pages/ts/index.tsx | 37 ----------- packages/dev-tools-pages/ts/pages/Base.tsx | 28 -------- packages/dev-tools-pages/ts/pages/Compiler.tsx | 13 +++- packages/dev-tools-pages/ts/pages/Cov.tsx | 13 +++- packages/dev-tools-pages/ts/pages/Profiler.tsx | 13 +++- packages/dev-tools-pages/ts/pages/Trace.tsx | 13 +++- packages/dev-tools-pages/webpack.config.js | 27 ++++++-- 27 files changed, 221 insertions(+), 133 deletions(-) create mode 100644 packages/dev-tools-pages/assets/crawl.html create mode 100644 packages/dev-tools-pages/assets/favicons/compiler.ico create mode 100644 packages/dev-tools-pages/assets/favicons/cov.ico create mode 100644 packages/dev-tools-pages/assets/favicons/profiler.ico create mode 100644 packages/dev-tools-pages/assets/favicons/trace.ico create mode 100644 packages/dev-tools-pages/assets/index.html create mode 100644 packages/dev-tools-pages/pages.js delete mode 100644 packages/dev-tools-pages/public/favicons/compiler.ico delete mode 100644 packages/dev-tools-pages/public/favicons/cov.ico delete mode 100644 packages/dev-tools-pages/public/favicons/profiler.ico delete mode 100644 packages/dev-tools-pages/public/favicons/trace.ico delete mode 100644 packages/dev-tools-pages/public/index.html create mode 100644 packages/dev-tools-pages/ts/components/Base.tsx delete mode 100644 packages/dev-tools-pages/ts/components/MetaTags.tsx create mode 100644 packages/dev-tools-pages/ts/highlight.tsx delete mode 100644 packages/dev-tools-pages/ts/index.tsx delete mode 100644 packages/dev-tools-pages/ts/pages/Base.tsx (limited to 'packages') diff --git a/packages/dev-tools-pages/.gitignore b/packages/dev-tools-pages/.gitignore index 6446c8579..9e9db7dae 100644 --- a/packages/dev-tools-pages/.gitignore +++ b/packages/dev-tools-pages/.gitignore @@ -1 +1,2 @@ -/public/fonts \ No newline at end of file +public +assets/fonts \ No newline at end of file diff --git a/packages/dev-tools-pages/assets/crawl.html b/packages/dev-tools-pages/assets/crawl.html new file mode 100644 index 000000000..9135c3ede --- /dev/null +++ b/packages/dev-tools-pages/assets/crawl.html @@ -0,0 +1,20 @@ + + + + + + + Document + + + + + + + \ No newline at end of file diff --git a/packages/dev-tools-pages/assets/favicons/compiler.ico b/packages/dev-tools-pages/assets/favicons/compiler.ico new file mode 100644 index 000000000..e43c5fc8a Binary files /dev/null and b/packages/dev-tools-pages/assets/favicons/compiler.ico differ diff --git a/packages/dev-tools-pages/assets/favicons/cov.ico b/packages/dev-tools-pages/assets/favicons/cov.ico new file mode 100644 index 000000000..4f1172186 Binary files /dev/null and b/packages/dev-tools-pages/assets/favicons/cov.ico differ diff --git a/packages/dev-tools-pages/assets/favicons/profiler.ico b/packages/dev-tools-pages/assets/favicons/profiler.ico new file mode 100644 index 000000000..65d38812b Binary files /dev/null and b/packages/dev-tools-pages/assets/favicons/profiler.ico differ diff --git a/packages/dev-tools-pages/assets/favicons/trace.ico b/packages/dev-tools-pages/assets/favicons/trace.ico new file mode 100644 index 000000000..af00455d4 Binary files /dev/null and b/packages/dev-tools-pages/assets/favicons/trace.ico differ diff --git a/packages/dev-tools-pages/assets/index.html b/packages/dev-tools-pages/assets/index.html new file mode 100644 index 000000000..5ab1a45f1 --- /dev/null +++ b/packages/dev-tools-pages/assets/index.html @@ -0,0 +1,14 @@ + + + + + + + + + <%= htmlWebpackPlugin.options.title %> + + +
+ + \ No newline at end of file diff --git a/packages/dev-tools-pages/package.json b/packages/dev-tools-pages/package.json index 8fb4bed7b..eb34e3715 100644 --- a/packages/dev-tools-pages/package.json +++ b/packages/dev-tools-pages/package.json @@ -7,7 +7,7 @@ "private": true, "description": "0x Dev tools pages", "scripts": { - "build": "node --max_old_space_size=8192 ../../node_modules/.bin/webpack --mode production", + "build": "node --max_old_space_size=8192 ../../node_modules/.bin/webpack --mode production && react-snap", "build:ci": "yarn build", "build:dev": "../../node_modules/.bin/webpack --mode development", "clean": "shx rm -f public/bundle*", @@ -28,7 +28,7 @@ "styled-normalize": "^8.0.1" }, "devDependencies": { - "@reach/router": "^1.2.1", + "@types/highlight.js": "^9.12.3", "@types/lodash": "4.14.104", "@types/node": "*", "@types/reach__router": "^1.2.0", @@ -40,11 +40,15 @@ "@types/react-tap-event-plugin": "0.0.30", "@types/styled-components": "^4.0.1", "awesome-typescript-loader": "^5.2.1", + "clean-webpack-plugin": "^0.1.19", + "copy-webpack-plugin": "^4.5.4", "copyfiles": "^2.0.0", "css-loader": "0.23.x", + "html-webpack-plugin": "^3.2.0", "less-loader": "^4.1.0", "make-promises-safe": "^1.1.0", "raw-loader": "^0.5.1", + "react-snap": "^1.19.0", "react-svg-loader": "^2.1.0", "shx": "^0.2.2", "source-map-loader": "^0.2.4", @@ -55,7 +59,11 @@ "typescript": "3.0.1", "uglifyjs-webpack-plugin": "^2.0.1", "webpack": "^4.20.2", + "webpack-bundle-analyzer": "^3.0.3", "webpack-cli": "3.1.2", "webpack-dev-server": "^3.1.9" + }, + "reactSnap": { + "source": "public" } } diff --git a/packages/dev-tools-pages/pages.js b/packages/dev-tools-pages/pages.js new file mode 100644 index 000000000..581904068 --- /dev/null +++ b/packages/dev-tools-pages/pages.js @@ -0,0 +1,72 @@ +const pages = [ + { + title: 'sol-compiler', + filename: 'compiler/index.html', + template: 'assets/index.html', + chunks: ['compiler'], + favicon: 'assets/favicons/compiler.ico', + minify: true, + meta: { + description: 'Solidity compilation that just works', + 'og-title': { property: 'og:title', content: 'sol-compiler' }, + 'og-description': { property: 'og:description', content: 'Solidity compilation that just works' }, + 'og-type': { property: 'og:type', content: 'website' }, + 'og-image': { property: 'og:image', content: '' }, + 'twitter:site': '@0xproject', + 'twitter:image': '', + }, + }, + { + title: 'sol-cov', + filename: 'cov/index.html', + template: 'assets/index.html', + chunks: ['cov'], + favicon: 'assets/favicons/cov.ico', + minify: true, + meta: { + description: 'Solidity code coverage', + 'og-title': { property: 'og:title', content: 'sol-cov' }, + 'og-description': { property: 'og:description', content: 'Solidity code coverage' }, + 'og-type': { property: 'og:type', content: 'website' }, + 'og-image': { property: 'og:image', content: '' }, + 'twitter:site': '@0xproject', + 'twitter:image': '', + }, + }, + { + title: 'sol-profiler', + filename: 'profiler/index.html', + template: 'assets/index.html', + chunks: ['profiler'], + favicon: 'assets/favicons/profiler.ico', + minify: true, + meta: { + description: 'Gas profiling for Solidity', + 'og-title': { property: 'og:title', content: 'sol-profiler' }, + 'og-description': { property: 'og:description', content: 'Gas profiling for Solidity' }, + 'og-type': { property: 'og:type', content: 'website' }, + 'og-image': { property: 'og:image', content: '' }, + 'twitter:site': '@0xproject', + 'twitter:image': '', + }, + }, + { + title: 'sol-trace', + filename: 'trace/index.html', + template: 'assets/index.html', + chunks: ['trace'], + favicon: 'assets/favicons/trace.ico', + minify: true, + meta: { + description: 'Human-readable stack traces', + 'og-title': { property: 'og:title', content: 'sol-trace' }, + 'og-description': { property: 'og:description', content: 'Human-readable stack traces' }, + 'og-type': { property: 'og:type', content: 'website' }, + 'og-image': { property: 'og:image', content: '' }, + 'twitter:site': '@0xproject', + 'twitter:image': '', + }, + }, +]; + +module.exports = pages; diff --git a/packages/dev-tools-pages/public/favicons/compiler.ico b/packages/dev-tools-pages/public/favicons/compiler.ico deleted file mode 100644 index e43c5fc8a..000000000 Binary files a/packages/dev-tools-pages/public/favicons/compiler.ico and /dev/null differ diff --git a/packages/dev-tools-pages/public/favicons/cov.ico b/packages/dev-tools-pages/public/favicons/cov.ico deleted file mode 100644 index 4f1172186..000000000 Binary files a/packages/dev-tools-pages/public/favicons/cov.ico and /dev/null differ diff --git a/packages/dev-tools-pages/public/favicons/profiler.ico b/packages/dev-tools-pages/public/favicons/profiler.ico deleted file mode 100644 index 65d38812b..000000000 Binary files a/packages/dev-tools-pages/public/favicons/profiler.ico and /dev/null differ diff --git a/packages/dev-tools-pages/public/favicons/trace.ico b/packages/dev-tools-pages/public/favicons/trace.ico deleted file mode 100644 index af00455d4..000000000 Binary files a/packages/dev-tools-pages/public/favicons/trace.ico and /dev/null differ diff --git a/packages/dev-tools-pages/public/index.html b/packages/dev-tools-pages/public/index.html deleted file mode 100644 index f8131aece..000000000 --- a/packages/dev-tools-pages/public/index.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - 0x: The Protocol for Trading Tokens - - - -
- - - - \ No newline at end of file diff --git a/packages/dev-tools-pages/ts/components/Base.tsx b/packages/dev-tools-pages/ts/components/Base.tsx new file mode 100644 index 000000000..16e9560f0 --- /dev/null +++ b/packages/dev-tools-pages/ts/components/Base.tsx @@ -0,0 +1,26 @@ +import * as React from 'react'; + +import ThemeContext from 'ts/context'; +import GlobalStyles from 'ts/globalStyles'; +import Header from 'ts/components/Header'; +import Hero from 'ts/components/Hero'; +import Footer from 'ts/components/Footer'; + +interface BaseProps { + context: any; + children: React.ReactNode; +} + +function Base(props: BaseProps) { + return ( + + +
+ + {props.children} +