-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(docsite): add build time script to fix the website title from Web…
…pack App to Fluent UI React v9
- Loading branch information
1 parent
18a7818
commit f970d9f
Showing
2 changed files
with
21 additions
and
1 deletion.
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,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); | ||
} |
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 |
---|---|---|
|
@@ -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", | ||
|