Skip to content

Commit f632cd9

Browse files
brijeshb42Brijesh Bittu
and
Brijesh Bittu
authored
[example] Update vite example (mui#300)
Co-authored-by: Brijesh Bittu <[email protected]>
1 parent b9d3611 commit f632cd9

9 files changed

+89
-29
lines changed

examples/.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module.exports = {
1111
'import/order': 'off',
1212
// create-vite generates .jsx
1313
'react/jsx-filename-extension': 'off',
14+
'react/react-in-jsx-scope': 'off',
1415
},
1516
overrides: [
1617
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import js from '@eslint/js';
2+
import globals from 'globals';
3+
import reactHooks from 'eslint-plugin-react-hooks';
4+
import reactRefresh from 'eslint-plugin-react-refresh';
5+
import tseslint from 'typescript-eslint';
6+
7+
export default tseslint.config(
8+
{ ignores: ['dist'] },
9+
{
10+
extends: [js.configs.recommended, ...tseslint.configs.recommended],
11+
files: ['**/*.{ts,tsx}'],
12+
languageOptions: {
13+
ecmaVersion: 2020,
14+
globals: globals.browser,
15+
},
16+
plugins: {
17+
'react-hooks': reactHooks,
18+
'react-refresh': reactRefresh,
19+
},
20+
rules: {
21+
...reactHooks.configs.recommended.rules,
22+
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
23+
},
24+
},
25+
);

examples/pigment-css-vite-ts/index.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<!doctype html>
22
<html lang="en">
33
<head>
4-
<meta charset="utf-8" />
4+
<meta charset="UTF-8" />
55
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6-
<meta name="viewport" content="initial-scale=1, width=device-width" />
7-
<title>Pigment CSS + Vite + TypeScript</title>
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + React + TS</title>
88
</head>
99
<body>
1010
<div id="root"></div>

examples/pigment-css-vite-ts/package.json

+10-2
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,28 @@
44
"type": "module",
55
"scripts": {
66
"dev": "vite",
7-
"build": "tsc && vite build",
7+
"build": "tsc -b && vite build",
8+
"lint": "eslint .",
89
"preview": "vite preview"
910
},
1011
"dependencies": {
1112
"@pigment-css/react": "latest",
13+
"prop-types": "latest",
1214
"react": "latest",
1315
"react-dom": "latest"
1416
},
1517
"devDependencies": {
18+
"@eslint/js": "latest",
1619
"@pigment-css/vite-plugin": "latest",
1720
"@types/react": "latest",
1821
"@types/react-dom": "latest",
19-
"@vitejs/plugin-react": "latest",
22+
"@vitejs/plugin-react-swc": "latest",
23+
"eslint": "latest",
24+
"eslint-plugin-react-hooks": "latest",
25+
"eslint-plugin-react-refresh": "latest",
26+
"globals": "latest",
2027
"typescript": "latest",
28+
"typescript-eslint": "latest",
2129
"vite": "latest"
2230
}
2331
}

examples/pigment-css-vite-ts/src/App.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as React from 'react';
21
import { styled, css, keyframes } from '@pigment-css/react';
32

43
const scale = keyframes({
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"compilerOptions": {
3+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
4+
"target": "ES2020",
5+
"useDefineForClassFields": true,
6+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
7+
"module": "ESNext",
8+
"skipLibCheck": true,
9+
10+
/* Bundler mode */
11+
"moduleResolution": "Bundler",
12+
"allowImportingTsExtensions": true,
13+
"isolatedModules": true,
14+
"moduleDetection": "force",
15+
"noEmit": true,
16+
"jsx": "react-jsx",
17+
18+
/* Linting */
19+
"strict": true,
20+
"noUnusedLocals": true,
21+
"noUnusedParameters": true,
22+
"noFallthroughCasesInSwitch": true,
23+
"noUncheckedSideEffectImports": true
24+
},
25+
"include": ["src"]
26+
}
+2-19
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,4 @@
11
{
2-
"compilerOptions": {
3-
"target": "ESNext",
4-
"useDefineForClassFields": true,
5-
"lib": ["DOM", "DOM.Iterable", "ESNext"],
6-
"allowJs": false,
7-
"skipLibCheck": true,
8-
"esModuleInterop": false,
9-
"allowSyntheticDefaultImports": true,
10-
"strict": true,
11-
"forceConsistentCasingInFileNames": true,
12-
"module": "ESNext",
13-
"moduleResolution": "Node",
14-
"resolveJsonModule": true,
15-
"isolatedModules": true,
16-
"noEmit": true,
17-
"jsx": "react-jsx"
18-
},
19-
"include": ["src"],
20-
"references": [{ "path": "./tsconfig.node.json" }]
2+
"files": [],
3+
"references": [{ "path": "./tsconfig.app.json" }, { "path": "./tsconfig.node.json" }]
214
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
11
{
22
"compilerOptions": {
3-
"composite": true,
3+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
4+
"target": "ES2022",
5+
"lib": ["ES2023"],
46
"module": "ESNext",
5-
"moduleResolution": "Node",
6-
"allowSyntheticDefaultImports": true
7+
"skipLibCheck": true,
8+
9+
/* Bundler mode */
10+
"moduleResolution": "Bundler",
11+
"allowImportingTsExtensions": true,
12+
"isolatedModules": true,
13+
"moduleDetection": "force",
14+
"noEmit": true,
15+
16+
/* Linting */
17+
"strict": true,
18+
"noUnusedLocals": true,
19+
"noUnusedParameters": true,
20+
"noFallthroughCasesInSwitch": true,
21+
"noUncheckedSideEffectImports": true
722
},
823
"include": ["vite.config.ts"]
924
}

examples/pigment-css-vite-ts/vite.config.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { defineConfig } from 'vite';
2-
import react from '@vitejs/plugin-react';
2+
import react from '@vitejs/plugin-react-swc';
33
import { pigment, extendTheme } from '@pigment-css/vite-plugin';
44

55
// To learn more about theming, visit https://github.com/mui/pigment-css/blob/master/README.md#theming
@@ -32,4 +32,7 @@ export default defineConfig({
3232
}),
3333
react(),
3434
],
35+
optimizeDeps: {
36+
include: ['react-is', 'prop-types'],
37+
},
3538
});

0 commit comments

Comments
 (0)