(react) publish storybook to github pages

In order to make the storybook visible to everyone. Some changes
had to be made to make index.scss compiled with the rest of the
codebase, it had to be imported from preview.js, not directly from
preview.html.
This commit is contained in:
Nathan Vasse
2023-01-20 12:06:18 +01:00
committed by NathanVss
parent 9bd7317796
commit c032e2e951
6 changed files with 195 additions and 32 deletions

View File

@@ -1,33 +1,32 @@
const viteTsconfig = require('vite-tsconfig-paths');
const tsconfigPaths = viteTsconfig.default;
const { mergeConfig } = require('vite');
module.exports = {
"stories": [
"../src/**/*.stories.mdx",
"../src/**/*.stories.@(js|jsx|ts|tsx)"
'stories': [
'../src/**/*.stories.mdx',
'../src/**/*.stories.@(js|jsx|ts|tsx)',
],
"addons": [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
'@storybook/preset-scss'
'addons': [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
],
"framework": "@storybook/react",
"core": {
"builder": "@storybook/builder-vite"
'framework': '@storybook/react',
'core': {
'builder': '@storybook/builder-vite',
},
staticDirs: [
'dist',
'../src'
'../src',
],
"features": {
"storyStoreV7": true
'features': {
'storyStoreV7': true,
},
async viteFinal(config) {
return mergeConfig(config, {
const finalConfig = mergeConfig(config, {
plugins: [tsconfigPaths()],
});
finalConfig.base = 'https://openfun.github.io/cunningham';
return finalConfig;
},
}
};

View File

@@ -1,4 +1,3 @@
<link rel='stylesheet' type='text/css' href='/src/index.scss'>
<style>
code {
margin: 0 2px;

View File

@@ -1,3 +1,5 @@
import '../src/index.scss'
export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {

View File

@@ -27,7 +27,8 @@
"test": "FORCE_COLOR=1 vitest run",
"test-watch": "vitest",
"coverage": "vitest run --coverage",
"storybook": "start-storybook -p 6006"
"storybook": "start-storybook -p 6006",
"deploy-storybook": "storybook-to-ghpages"
},
"dependencies": {
"@fontsource/roboto": "4.5.8",
@@ -49,6 +50,7 @@
"@storybook/builder-vite": "0.2.6",
"@storybook/preset-scss": "1.0.3",
"@storybook/react": "6.5.15",
"@storybook/storybook-deployer": "^2.8.16",
"@storybook/testing-library": "0.0.13",
"@testing-library/dom": "8.19.1",
"@testing-library/react": "13.4.0",