Skip to content

Commit

Permalink
[example] Update vite example (#300)
Browse files Browse the repository at this point in the history
Co-authored-by: Brijesh Bittu <[email protected]>
  • Loading branch information
brijeshb42 and Brijesh Bittu authored Nov 5, 2024
1 parent b9d3611 commit f632cd9
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 29 deletions.
1 change: 1 addition & 0 deletions examples/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = {
'import/order': 'off',
// create-vite generates .jsx
'react/jsx-filename-extension': 'off',
'react/react-in-jsx-scope': 'off',
},
overrides: [
{
Expand Down
25 changes: 25 additions & 0 deletions examples/pigment-css-vite-ts/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import js from '@eslint/js';
import globals from 'globals';
import reactHooks from 'eslint-plugin-react-hooks';
import reactRefresh from 'eslint-plugin-react-refresh';
import tseslint from 'typescript-eslint';

export default tseslint.config(
{ ignores: ['dist'] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
},
},
);
6 changes: 3 additions & 3 deletions examples/pigment-css-vite-ts/index.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="initial-scale=1, width=device-width" />
<title>Pigment CSS + Vite + TypeScript</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
Expand Down
12 changes: 10 additions & 2 deletions examples/pigment-css-vite-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,28 @@
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"@pigment-css/react": "latest",
"prop-types": "latest",
"react": "latest",
"react-dom": "latest"
},
"devDependencies": {
"@eslint/js": "latest",
"@pigment-css/vite-plugin": "latest",
"@types/react": "latest",
"@types/react-dom": "latest",
"@vitejs/plugin-react": "latest",
"@vitejs/plugin-react-swc": "latest",
"eslint": "latest",
"eslint-plugin-react-hooks": "latest",
"eslint-plugin-react-refresh": "latest",
"globals": "latest",
"typescript": "latest",
"typescript-eslint": "latest",
"vite": "latest"
}
}
1 change: 0 additions & 1 deletion examples/pigment-css-vite-ts/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { styled, css, keyframes } from '@pigment-css/react';

const scale = keyframes({
Expand Down
26 changes: 26 additions & 0 deletions examples/pigment-css-vite-ts/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "Bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["src"]
}
21 changes: 2 additions & 19 deletions examples/pigment-css-vite-ts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
"files": [],
"references": [{ "path": "./tsconfig.app.json" }, { "path": "./tsconfig.node.json" }]
}
21 changes: 18 additions & 3 deletions examples/pigment-css-vite-ts/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
{
"compilerOptions": {
"composite": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"target": "ES2022",
"lib": ["ES2023"],
"module": "ESNext",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "Bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["vite.config.ts"]
}
5 changes: 4 additions & 1 deletion examples/pigment-css-vite-ts/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import react from '@vitejs/plugin-react-swc';
import { pigment, extendTheme } from '@pigment-css/vite-plugin';

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

0 comments on commit f632cd9

Please sign in to comment.