Skip to content

Commit 4a38093

Browse files
add figma publish hook script
1 parent 9c59b9e commit 4a38093

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

figma/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
},
1010
"scripts": {
1111
"clean": "rimraf dist",
12-
"build": "yarn clean && webpack --mode=production --host=production",
12+
"build": "yarn clean && webpack --mode=production --host=production && yarn prepublish",
13+
"prepublish": "node scripts/prepublish.js",
1314
"build:staging": "yarn clean && webpack --mode=production --host=staging",
1415
"build:dev": "webpack --mode=development --host=dev",
1516
"watch": "webpack --watch",

figma/scripts/prepublish.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// before publishing update to figma, clean the dist forder for the size reduction.
2+
// leave only dist/code.js and dist/ui.js under the dist folder (remove all other files)
3+
4+
const fs = require("fs");
5+
const path = require("path");
6+
7+
const distPath = path.join(__dirname, "../dist");
8+
9+
fs.readdirSync(distPath).forEach((file) => {
10+
if (file !== "code.js" && file !== "ui.js") {
11+
fs.unlink(path.join(distPath, file), (err) => {
12+
if (err) throw err;
13+
});
14+
}
15+
});

0 commit comments

Comments
 (0)