use Vite in @status-im/components

This commit is contained in:
Pavel Prichodko 2023-03-13 22:52:43 +01:00
parent 05d4a54c14
commit 9d45202b8d
No known key found for this signature in database
GPG Key ID: 0EB8D75C775AB6F1
3 changed files with 46 additions and 17 deletions

View File

@ -5,15 +5,16 @@
"*.css" "*.css"
], ],
"private": true, "private": true,
"types": "src/index.tsx", "main": "./dist/index.js",
"main": "src/index.tsx", "module": "./dist/index.mjs",
"types": "./dist/types/index.d.ts",
"files": [ "files": [
"types", "types",
"dist" "dist"
], ],
"scripts": { "scripts": {
"dev": "tamagui-build --watch", "dev": "TAMAGUI_TARGET='web' vite build --watch --mode development",
"build": "tamagui-build", "build": "TAMAGUI_TARGET='web' vite build",
"postbuild": "yarn typegen", "postbuild": "yarn typegen",
"typegen": "tsc --noEmit false --emitDeclarationOnly || true", "typegen": "tsc --noEmit false --emitDeclarationOnly || true",
"lint": "eslint src", "lint": "eslint src",
@ -50,8 +51,8 @@
"@storybook/react": "7.0.0-beta.21", "@storybook/react": "7.0.0-beta.21",
"@storybook/react-vite": "7.0.0-beta.21", "@storybook/react-vite": "7.0.0-beta.21",
"@storybook/testing-library": "^0.0.13", "@storybook/testing-library": "^0.0.13",
"@tamagui/build": "1.7.7",
"@tamagui/vite-plugin": "1.7.7", "@tamagui/vite-plugin": "1.7.7",
"@vitejs/plugin-react-swc": "^3.2.0",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-native-svg": "^13.8.0", "react-native-svg": "^13.8.0",

View File

@ -1,4 +1,3 @@
import { Divider, IconButton, Paragraph } from '@status-im/components'
import { import {
ArrowLeftIcon, ArrowLeftIcon,
CommunitiesIcon, CommunitiesIcon,
@ -14,7 +13,10 @@ import {
import { Stack, Text } from '@tamagui/core' import { Stack, Text } from '@tamagui/core'
import { BlurView } from 'expo-blur' import { BlurView } from 'expo-blur'
import { Divider } from '../divider'
import { DropdownMenu } from '../dropdown-menu' import { DropdownMenu } from '../dropdown-menu'
import { IconButton } from '../icon-button'
import { Paragraph } from '../typography'
import type { Channel } from '../sidebar/mock-data' import type { Channel } from '../sidebar/mock-data'

View File

@ -2,7 +2,7 @@ import { tamaguiPlugin } from '@tamagui/vite-plugin'
import react from '@vitejs/plugin-react-swc' import react from '@vitejs/plugin-react-swc'
import { defineConfig } from 'vite' import { defineConfig } from 'vite'
import type { PluginOption } from 'vite' import { dependencies, peerDependencies } from './package.json'
const tamaguiConfig = { const tamaguiConfig = {
components: [], components: [],
@ -10,14 +10,40 @@ const tamaguiConfig = {
// useReactNativeWebLite: true, // useReactNativeWebLite: true,
} }
// https://vitejs.dev/config const external = [
export default defineConfig({ ...Object.keys(dependencies || {}),
define: { ...Object.keys(peerDependencies || {}),
TAMAGUI_TARGET: JSON.stringify('web'), ].map(name => new RegExp(`^${name}(/.*)?`))
},
plugins: [ export default defineConfig(({ mode }) => {
react(), return {
tamaguiPlugin(tamaguiConfig) as PluginOption, define: {
// tamaguiExtractPlugin(tamaguiConfig) TAMAGUI_TARGET: JSON.stringify('web'),
], },
build: {
target: 'es2020',
lib: {
entry: './src/index.tsx',
fileName: 'index',
formats: ['es', 'cjs'],
},
sourcemap: true,
emptyOutDir: mode === 'production',
rollupOptions: {
external,
},
},
plugins: [
react({
// jsxRuntime: 'classic',
}),
tamaguiPlugin(tamaguiConfig),
// tamaguiExtractPlugin(tamaguiConfig)
],
test: {
environment: 'happy-dom',
},
}
}) })