Skip to content

Commit 4cbed8b

Browse files
authored
Merge pull request #1 from bigtimebuddy/master
Chore: Clean-up, Fixes and Dependency Updates
2 parents ad75841 + b49823f commit 4cbed8b

File tree

12 files changed

+2666
-2561
lines changed

12 files changed

+2666
-2561
lines changed

README.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
4. **_Bundled into One File:_** Figma plugins only accept a single file for `main` (js) and `ui` (html), which makes deployment of multiple files linked to each other impossible. This boilerplate is configured to bundle/inline most of the things you need like rasterize/vector image asset imports, CSS URL statements, and of course, source code imports.
4242

43-
5. **_SVG as Component:_** Yes, you can import SVGs as inlined sources with `*.svg?inline`, but what about actually importing them as React components? Easy! You can import an SVG file as a React component with `*.svg?component!` (See `/src/ui/app.tsx` for examples)
43+
5. **_SVG as Component:_** Yes, you can import SVGs as inlined sources with `*.svg?inline`, but what about actually importing them as React components? Easy! You can import an SVG file as a React component with `*.svg?react` (See `/src/ui/app.tsx` for examples)
4444

4545
6. **_Sassy:_** A classic, this boilerplate supports Sass/Scss/Less and modules! Check out `/src/ui/styles/` for 7-1 Sass Template and `/src/ui/components/Button.module.scss` for module examples.
4646

@@ -62,7 +62,7 @@ npm i
6262
Since UI is powered by Vite + React, you can use your browser to code the UI with HMR but **without** the figma context. Just run the following command line:
6363

6464
```
65-
npm run dev
65+
npm start
6666
```
6767

6868
### Building
@@ -94,16 +94,11 @@ After building, built `dist` folder is going to contain every artifact you need
9494

9595
### 1. Make sure to either inline or component SVG imports!
9696

97-
Importing image assets other than `.svg` is easy. However, when you are importing `.svg` you MUST make sure it is imported using either one of the suffixes `?inline` or `?component`.
97+
Importing image assets other than `.svg` is easy. However, when you are importing `.svg`, by default it will load as a base64 data-uri, to import as a React component, you must add the query string `?react`.
9898

9999
```tsx
100-
// ❌ WRONG! Won't be visible in Figma
101-
import myImage from "@ui/assets/my_image.svg";
102-
103-
// ✔️ Correct!
104-
import MyImage from "@ui/assets/my_image.svg?component";
105-
import myImage from "@ui/assets/my_image.svg?inline";
106-
100+
import MyImage from "@ui/assets/my_image.svg?react"; // Import as React component
101+
import myImage from "@ui/assets/my_image.svg"; // Import as base64 data-uri
107102
...
108103

109104
<MyImage className="something" />

package-lock.json

Lines changed: 2594 additions & 2381 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,19 @@
44
"version": "0.0.0",
55
"type": "module",
66
"scripts": {
7-
"dev": "vite -c ./vite.config.ui.ts",
8-
"build": "tsc && npm run build:ui && npm run build:plugin && cross-os refresh-figma",
9-
"build:ui": "vite build -c ./vite.config.ui.ts --emptyOutDir",
10-
"build:plugin": "vite build -c ./vite.config.plugin.ts",
11-
"preview": "vite preview"
7+
"start": "run-s watch",
8+
"watch": "run-p watch:*",
9+
"watch:ui": "npm run build:ui -- --watch --mode=development",
10+
"watch:plugin": "npm run build:plugin -- --watch --mode=development",
11+
"clean": "rimraf dist/*",
12+
"prebuild": "run-s types clean",
13+
"types": "run-s types:*",
14+
"types:src": "tsc",
15+
"types:node": "tsc -P tsconfig.node.json",
16+
"build": "run-s build:*",
17+
"postbuild": "cross-os refresh-figma",
18+
"build:ui": "vite build -c ./vite.config.ui.ts",
19+
"build:plugin": "vite build -c ./vite.config.plugin.ts"
1220
},
1321
"cross-os": {
1422
"refresh-figma": {
@@ -21,21 +29,23 @@
2129
"react-dom": "^18.2.0"
2230
},
2331
"devDependencies": {
24-
"@figma/plugin-typings": "^1.62.0",
25-
"@svgr/core": "^6.5.1",
32+
"@figma/plugin-typings": "^1.83.0",
33+
"@rollup/pluginutils": "^5.1.0",
2634
"@types/node": "^18.15.11",
2735
"@types/postcss-url": "^10.0.0",
2836
"@types/react": "^18.0.28",
2937
"@types/react-dom": "^18.0.11",
30-
"@vitejs/plugin-react": "^3.1.0",
38+
"@vitejs/plugin-react": "^4.2.1",
3139
"cross-os": "^1.5.0",
40+
"npm-run-all": "^4.1.5",
3241
"postcss": "^8.4.21",
3342
"postcss-url": "^10.1.3",
43+
"rimraf": "^5.0.5",
3444
"sass": "^1.60.0",
35-
"typescript": "^4.9.3",
36-
"vite": "^4.2.0",
37-
"vite-plugin-generate-file": "^0.0.4",
38-
"vite-plugin-singlefile": "^0.13.3",
39-
"vite-plugin-svgr": "^2.4.0"
45+
"typescript": "^5.3.0",
46+
"vite": "^5.0.11",
47+
"vite-plugin-generate-file": "^0.1.1",
48+
"vite-plugin-singlefile": "^0.13.5",
49+
"vite-plugin-svgr": "^4.2.0"
4050
}
4151
}

scripts/vite/vite-inline-svg.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.

scripts/vite/vite-svgr-component.ts

Lines changed: 0 additions & 50 deletions
This file was deleted.

src/ui/app.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { useState } from "react";
22
import * as Networker from "monorepo-networker";
33
import { NetworkMessages } from "@common/network/messages";
44

5-
import ReactLogo from "@ui/assets/react.svg?component";
6-
import viteLogo from "@ui/assets/vite.svg?inline";
5+
import ReactLogo from "@ui/assets/react.svg?react";
6+
import viteLogo from "@ui/assets/vite.svg";
77
import figmaLogo from "@ui/assets/figma.png";
88

99
import { Button } from "@ui/components/Button";

src/ui/index.html

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,2 @@
1-
<!DOCTYPE html>
2-
<html lang="en">
3-
<head>
4-
<meta charset="UTF-8" />
5-
<link rel="icon" type="image/svg+xml" href="./assets/vite.svg" />
6-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<title>Figma + Vite + React</title>
8-
</head>
9-
<body>
10-
<div id="root"></div>
11-
<script type="module" src="./main.tsx"></script>
12-
</body>
13-
</html>
1+
<div id="root"></div>
2+
<script type="module" src="./main.tsx"></script>

src/ui/vite-env.d.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,2 @@
11
/// <reference types="vite/client" />
2-
3-
declare module "*.svg?component" {
4-
import * as React from "react";
5-
6-
const ReactComponent: React.FunctionComponent<
7-
React.ComponentProps<"svg"> & { title?: string }
8-
>;
9-
10-
export default ReactComponent;
11-
}
2+
/// <reference types="vite-plugin-svgr/client" />

tsconfig.json

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,27 @@
11
{
22
"compilerOptions": {
3-
"target": "ES2020",
4-
"module": "ES2020",
3+
"target": "ES2022",
4+
"module": "ES2022",
5+
"moduleResolution": "Node",
56
"useDefineForClassFields": true,
6-
"allowJs": false,
77
"skipLibCheck": true,
8-
"esModuleInterop": false,
9-
"allowSyntheticDefaultImports": true,
8+
"esModuleInterop": true,
109
"strict": true,
1110
"forceConsistentCasingInFileNames": true,
12-
"moduleResolution": "Node",
1311
"resolveJsonModule": true,
1412
"isolatedModules": false,
1513
"noEmit": true,
1614
"jsx": "react-jsx",
17-
"lib": ["DOM", "DOM.Iterable", "ESNext"],
18-
"typeRoots": ["./node_modules/@types/", "./node_modules/@figma"],
19-
"rootDir": ".",
20-
"baseUrl": ".",
21-
"outDir": "dist/",
22-
"sourceMap": false,
15+
"typeRoots": ["./node_modules/@figma"],
2316
"paths": {
2417
"@common/*": ["./src/common/*"],
2518
"@ui/*": ["./src/ui/*"],
2619
"@plugin/*": ["./src/plugin/*"]
2720
}
2821
},
2922
"include": [
30-
"src/**/*.d.ts",
3123
"src/**/*.d.ts",
3224
"src/**/*.ts",
33-
"src/**/*.tsx",
34-
"src/**/*.js",
35-
"src/**/*.jsx"
25+
"src/**/*.tsx"
3626
]
3727
}

tsconfig.node.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
{
22
"compilerOptions": {
3-
"composite": true,
3+
"noEmit": true,
4+
"skipLibCheck": true,
45
"module": "ESNext",
56
"moduleResolution": "Node",
6-
"allowSyntheticDefaultImports": true
7+
"esModuleInterop": true
78
},
89
"include": [
9-
"vite.config.plugin.ts",
10-
"vite.config.ui.ts",
11-
"./scripts/vite/*.ts"
10+
"*.ts"
1211
]
1312
}

0 commit comments

Comments
 (0)