-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
95 changed files
with
2,169 additions
and
2,005 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Build and Deploy Storybook | ||
on: | ||
push: | ||
branches: | ||
- master | ||
jobs: | ||
build-and-deploy-storybook: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v3 | ||
- name: Get yarn cache directory path | ||
id: yarn-cache-dir-path | ||
run: echo "::set-output name=dir::$(yarn cache dir)" | ||
- uses: actions/cache@v3 | ||
id: yarn-cache | ||
with: | ||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- name: Install modules | ||
run: yarn install --frozen-lockfile | ||
- name: Build Storybook | ||
run: yarn build:storybook | ||
- name: Deploy Storybook | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./storybook-static |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,70 @@ | ||
import { cpSync } from 'node:fs'; | ||
import { resolve } from 'node:path'; | ||
import { build as buildVite } from 'vite'; | ||
import { createServer as createViteServer } from 'vite'; | ||
|
||
const rootDir = process.cwd(); | ||
const outDir = resolve(rootDir, 'dist'); | ||
const outPublicDir = resolve(rootDir, 'dist/public'); | ||
const args = process.argv.slice(2).reduce<Record<string, string | number | boolean>>((currentArgs, currentArg) => { | ||
const [key, value] = currentArg.replace('--', '').split('='); | ||
currentArgs[key] = value; | ||
return currentArgs; | ||
}, {}); | ||
|
||
const copyImgs = (): void => { | ||
const srcDir = resolve(rootDir, '_assets'); | ||
const outputDir = resolve(rootDir, 'public/imgs'); | ||
cpSync(srcDir, outputDir, { recursive: true }); | ||
}; | ||
|
||
const generateFeeds = async (): Promise<void> => { | ||
const baseUrl = process.env.BASE_URL || '/'; | ||
|
||
const vite = await createViteServer({ | ||
server: { middlewareMode: true }, | ||
base: baseUrl, | ||
appType: 'custom', | ||
}); | ||
|
||
try { | ||
const { generateFeedFile } = await vite.ssrLoadModule('/src/helpers/feedHelper.ts'); | ||
generateFeedFile({ rootDir: outPublicDir }); | ||
} catch (e) { | ||
console.error(e); | ||
} finally { | ||
vite.close(); | ||
} | ||
}; | ||
|
||
const build = async (): Promise<void> => { | ||
// 1. Build Server | ||
buildVite({ | ||
base: process.env.BASE_URL || '/', | ||
build: { | ||
emptyOutDir: false, | ||
ssr: true, | ||
outDir: 'dist', | ||
rollupOptions: { | ||
input: 'src/server.ts', | ||
copyImgs(); | ||
if (args.ssr) { | ||
await buildVite({ | ||
base: process.env.BASE_URL || '/', | ||
build: { | ||
emptyOutDir: false, | ||
ssr: true, | ||
outDir: outDir, | ||
rollupOptions: { | ||
input: 'src/server.ts', | ||
}, | ||
}, | ||
}, | ||
mode: process.env.NODE_ENV || 'production', | ||
}); | ||
mode: process.env.NODE_ENV || 'production', | ||
}); | ||
} | ||
|
||
// 2. Build Client | ||
buildVite({ | ||
await buildVite({ | ||
base: process.env.BASE_URL || '/', | ||
build: { | ||
emptyOutDir: false, | ||
manifest: true, | ||
outDir: 'dist/public', | ||
outDir: outPublicDir, | ||
}, | ||
mode: process.env.NODE_ENV || 'production', | ||
}); | ||
|
||
generateFeeds(); | ||
}; | ||
|
||
build(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.