Skip to content

Commit

Permalink
add figma publish hook script
Browse files Browse the repository at this point in the history
  • Loading branch information
softmarshmallow committed Nov 16, 2022
1 parent 9c59b9e commit 4a38093
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion figma/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
},
"scripts": {
"clean": "rimraf dist",
"build": "yarn clean && webpack --mode=production --host=production",
"build": "yarn clean && webpack --mode=production --host=production && yarn prepublish",
"prepublish": "node scripts/prepublish.js",
"build:staging": "yarn clean && webpack --mode=production --host=staging",
"build:dev": "webpack --mode=development --host=dev",
"watch": "webpack --watch",
Expand Down
15 changes: 15 additions & 0 deletions figma/scripts/prepublish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// before publishing update to figma, clean the dist forder for the size reduction.
// leave only dist/code.js and dist/ui.js under the dist folder (remove all other files)

const fs = require("fs");
const path = require("path");

const distPath = path.join(__dirname, "../dist");

fs.readdirSync(distPath).forEach((file) => {
if (file !== "code.js" && file !== "ui.js") {
fs.unlink(path.join(distPath, file), (err) => {
if (err) throw err;
});
}
});

0 comments on commit 4a38093

Please sign in to comment.