Skip to content

Commit

Permalink
chore: Copies public folder files into built storybook artefact folder
Browse files Browse the repository at this point in the history
  • Loading branch information
amir-zahedi committed Apr 19, 2024
1 parent 2616971 commit f20bfbb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"start": "concurrently -k \"yarn:storybook\"",
"storybook:extract": "npx sb extract",
"storybook": "start-storybook -p 6006 -s public",
"storybook:build": "build-storybook -s public",
"storybook:build": "build-storybook -s public && yarn run copy:public",
"copy:public": "node scripts/copyPublic.js",
"test": "jest"
},
"browserslist": "extends browserslist-config-autoguru",
Expand Down
26 changes: 26 additions & 0 deletions scripts/copyPublic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const fs = require('fs');
const path = require('path');

const sourceDir = path.join(__dirname, '../', 'public');
const targetDir = path.join(__dirname, '../','storybook-static');

fs.readdir(sourceDir, (err, files) => {
if (err) {
console.error(`Unable to read directory: ${sourceDir}`);
process.exit(1);
}

files.forEach(file => {
const sourceFile = path.join(sourceDir, file);
const targetFile = path.join(targetDir, file);

if (!fs.existsSync(targetFile)) {
fs.copyFile(sourceFile, targetFile, err => {
if (err) {
console.error(`Unable to copy file: ${sourceFile}`);
process.exit(1);
}
});
}
});
});

0 comments on commit f20bfbb

Please sign in to comment.