Skip to content

Commit

Permalink
fix(docsite): add build time script to fix the website title from Web…
Browse files Browse the repository at this point in the history
…pack App to Fluent UI React v9
  • Loading branch information
tudorpopams committed Aug 10, 2022
1 parent 18a7818 commit f970d9f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions apps/public-docsite-v9/.storybook/fix-title.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const fs = require('fs');
const path = require('path');

try {
const args = process.argv.slice(2);
const [title, distPath] = args;

console.log(`Rewriting index.html document title to ${title}.`);

const filePath = `${distPath}/storybook/index.html`;
const document = fs.readFileSync(path.resolve(__dirname, filePath), 'utf8');
const output = document.replace(/<title>.*<\/title>/, `<title>${title}</title>`);

fs.writeFileSync(path.resolve(__dirname, filePath), output);
console.log('Title rewrite complete.');
} catch (error) {
console.log('Title rewrite failed.');
console.error(error);
process.exit(1);
}
2 changes: 1 addition & 1 deletion apps/public-docsite-v9/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "A collection of examples demonstrating how to upgrade from v8 to v9",
"scripts": {
"build": "just-scripts build",
"build-storybook": "build-storybook -o ./dist/storybook --docs",
"build-storybook": "build-storybook -o ./dist/storybook --docs && node ./.storybook/fix-title.js 'Fluent UI React v9' ../dist",
"chromatic:branch": "npx [email protected] --project-token $CHROMATIC_PROJECT_TOKEN --exit-zero-on-changes --build-script-name build-storybook",
"chromatic": "npx [email protected] --project-token $CHROMATIC_PROJECT_TOKEN --exit-zero-on-changes --build-script-name build-storybook --branch-name microsoft:master",
"clean": "just-scripts clean",
Expand Down

0 comments on commit f970d9f

Please sign in to comment.