Skip to content

Commit

Permalink
Deploy demo site along with docs
Browse files Browse the repository at this point in the history
  • Loading branch information
feihong committed Jan 18, 2024
1 parent 7355c33 commit 1952c76
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 13 deletions.
17 changes: 13 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Deploy VitePress site to Pages
on:
# Runs on pushes targeting the `main` branch.
push:
branches: [main]
branches: [demo]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -29,21 +29,30 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0 # Not needed if lastUpdated is not enabled
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: npm
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Install dependencies
- uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: 5.1.1
- name: Install all deps
run: make install
- name: Bundle the app
run: make bundle
- name: Install dependencies for VitePress
run: |
cd docs
npm ci
- name: Build with VitePress
run: |
cd docs
npm run docs:build
- name: Move demo site into docs dir
run: mv dist docs/.vitepress/dist/demo
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ serve: ## Serve an application using a local HTTP server
npx vite serve --open

.PHONY: bundle
bundle: ## Bundle the JavaScript application
bundle: build ## Bundle the JavaScript application
npx vite build

.PHONY: clean
clean: ## Clean build artifacts and other generated files
$(DUNE) clean
rm -rf dist

.PHONY: format
format: ## Format the codebase with ocamlformat
Expand Down
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Melange for React Developers</title>
</head>
<body>
Expand Down
3 changes: 2 additions & 1 deletion src/better-sandwiches/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Melange for React Devs</title>
<script type="module" src="../../_build/default/src/better-sandwiches/output/src/better-sandwiches/Index.js"></script>
</head>
Expand Down
3 changes: 2 additions & 1 deletion src/celsius-converter-exception/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Melange for React Devs</title>
<script type="module" src="../../_build/default/src/celsius-converter-exception/output/src/celsius-converter-exception/Index.js"></script>
</head>
Expand Down
3 changes: 2 additions & 1 deletion src/celsius-converter-option/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Melange for React Devs</title>
<script type="module" src="../../_build/default/src/celsius-converter-option/output/src/celsius-converter-option/Index.js"></script>
</head>
Expand Down
3 changes: 2 additions & 1 deletion src/counter/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Melange for React Devs</title>
<script type="module" src="../../_build/default/src/counter/output/src/counter/Index.js"></script>
</head>
Expand Down
3 changes: 2 additions & 1 deletion src/numeric-types/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Melange for React Devs</title>
<script type="module" src="../../_build/default/src/numeric-types/output/src/numeric-types/Index.js"></script>
</head>
Expand Down
3 changes: 2 additions & 1 deletion src/order-confirmation/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Melange for React Devs</title>
<script type="module" src="../../_build/default/src/order-confirmation/output/src/order-confirmation/Index.js"></script>
</head>
Expand Down
3 changes: 2 additions & 1 deletion src/styling-with-css/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Melange for React Devs</title>
<script type="module" src="../../_build/default/src/styling-with-css/output/src/styling-with-css/Index.js"></script>
</head>
Expand Down
15 changes: 15 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { defineConfig } from 'vite'
import { nodeResolve } from '@rollup/plugin-node-resolve'

export default defineConfig({
base: '/demo/',
// nodeResolve is needed to import melange runtime libraries in output
// directory's `node_modules` directory. See
// https://github.com/melange-re/melange-for-react-devs/pull/16#discussion_r1455989106
Expand All @@ -12,4 +13,18 @@ export default defineConfig({
ignored: ['**/_opam']
}
},
build: {
rollupOptions: {
input: {
main: resolve(__dirname, 'index.html'),
counter: resolve(__dirname, 'src/counter/index.html'),
'numeric-types': resolve(__dirname, 'src/numeric-types/index.html'),
'celsius-converter-exception': resolve(__dirname, 'src/celsius-converter-exception/index.html'),
'celsius-converter-option': resolve(__dirname, 'src/celsius-converter-option/index.html'),
'order-confirmation': resolve(__dirname, 'src/order-confirmation/index.html'),
'styling-with-css': resolve(__dirname, 'src/styling-with-css/index.html'),
'better-sandwiches': resolve(__dirname, 'src/better-sandwiches/index.html'),
},
},
},
});

0 comments on commit 1952c76

Please sign in to comment.