Skip to content

Commit

Permalink
Merge branch 'tamagui-reduce-css'
Browse files Browse the repository at this point in the history
  • Loading branch information
rmarscher committed Feb 2, 2024
2 parents e127215 + d86b483 commit 8a957a0
Show file tree
Hide file tree
Showing 9 changed files with 895 additions and 88 deletions.
4 changes: 2 additions & 2 deletions apps/expo/app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ SplashScreen.preventAutoHideAsync()

export default function RootLayout() {
const [loaded, error] = useFonts({
Inter: require('@tamagui/font-inter/otf/Inter-Medium.otf'),
InterBold: require('@tamagui/font-inter/otf/Inter-Bold.otf'),
// Inter: require('@tamagui/font-inter/otf/Inter-Medium.otf'),
// InterBold: require('@tamagui/font-inter/otf/Inter-Bold.otf'),
})

// Expo Router uses Error Boundaries to catch errors in the navigation tree.
Expand Down
2 changes: 1 addition & 1 deletion apps/expo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"devDependencies": {
"@babel/core": "^7.23.2",
"@expo/metro-config": "^0.10.7",
"@tamagui/babel-plugin": "1.75.9",
"@tamagui/babel-plugin": "1.88.18",
"metro-minify-terser": "^0.80.0",
"typescript": "^5.2.2"
}
Expand Down
100 changes: 57 additions & 43 deletions apps/next/next.config.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,67 @@
const { withTamagui } = require('@tamagui/next-plugin')
const { join } = require('path')
const million = require('million/compiler')
const pattycake = require('pattycake')
const withPWA = require('@ducanh2912/next-pwa').default({
dest: 'public',
disable: process.env.NODE_ENV === 'development',
const { withTamagui } = require("@tamagui/next-plugin");
const { join } = require("path");
const million = require("million/compiler");
const pattycake = require("pattycake");
const withPWA = require("@ducanh2912/next-pwa").default({
dest: "public",
disable: process.env.NODE_ENV === "development",
register: true,
sw: 'service-worker.js',
sw: "service-worker.js",
swcMinify: true,
})
});

const boolVals = {
true: true,
false: false,
}
};

const disableExtraction =
boolVals[process.env.DISABLE_EXTRACTION] ?? process.env.NODE_ENV === 'development'
boolVals[process.env.DISABLE_EXTRACTION] ??
process.env.NODE_ENV === "development";

const disableBrowserLogs =
boolVals[process.env.DISABLE_BROWSER_LOGS] ?? process.env.NODE_ENV === 'production'
boolVals[process.env.DISABLE_BROWSER_LOGS] ??
process.env.NODE_ENV === "production";

const enableMillionJS =
boolVals[process.env.ENABLE_MILLION_JS] ?? process.env.NODE_ENV === 'production'
boolVals[process.env.ENABLE_MILLION_JS] ??
process.env.NODE_ENV === "production";

// Temporarily disabled, produces chatty logs
const enablePattyCake = false
const enablePattyCake = false;
// boolVals[process.env.ENABLE_PATTY_CAKE] ?? process.env.NODE_ENV === 'production'

// Enabling causes FOUC on page refreshes
const optimizeCss = false
const optimizeCss = false;

const plugins = [
withPWA,
withTamagui({
appDir: true,
config: './tamagui.config.ts',
components: ['tamagui', '@t4/ui'],
importsWhitelist: ['constants.js', 'colors.js'],
outputCSS: process.env.NODE_ENV === 'production' ? './public/tamagui.css' : null,
emitSingleCSSFile: false,
doesMutateThemes: false,
config: "./tamagui.config.ts",
components: ["tamagui", "@t4/ui"],
importsWhitelist: ["constants.js", "colors.js"],
outputCSS:
process.env.NODE_ENV === "production" ? "./public/tamagui.css" : null,
logTimings: true,
disableExtraction,
enableCSSOptimizations: true,
excludeReactNativeWebExports: [
"Switch",
"ProgressBar",
"Picker",
"CheckBox",
"Touchable",
],
shouldExtract: (path) => {
if (path.includes(join('packages', 'app'))) {
return true
if (path.includes(join("packages", "app"))) {
return true;
}
},
}),
]
];

// If using nextjs edge runtime and need cloudflare bindings:
// if (process.env.NODE_ENV === 'development') {
Expand Down Expand Up @@ -82,20 +96,20 @@ module.exports = function () {
ignoreBuildErrors: true,
},
modularizeImports: {
'@tamagui/lucide-icons': {
transform: '@tamagui/lucide-icons/dist/esm/icons/{{kebabCase member}}',
"@tamagui/lucide-icons": {
transform: "@tamagui/lucide-icons/dist/esm/icons/{{kebabCase member}}",
skipDefaultConversion: true,
},
},
transpilePackages: [
'solito',
'react-native-web',
'expo-linking',
'expo-constants',
'expo-modules-core',
'react-native-safe-area-context',
'react-native-reanimated',
'react-native-gesture-handler',
"solito",
"react-native-web",
"expo-linking",
"expo-constants",
"expo-modules-core",
"react-native-safe-area-context",
"react-native-reanimated",
"react-native-gesture-handler",
],
experimental: {
optimizeCss,
Expand All @@ -104,7 +118,7 @@ module.exports = function () {
scrollRestoration: true,
swcPlugins: [
[
'next-superjson-plugin',
"next-superjson-plugin",
{
excluded: [],
},
Expand All @@ -117,34 +131,34 @@ module.exports = function () {
async rewrites() {
return [
{
source: '/worker/:path*',
source: "/worker/:path*",
destination: process.env.NEXT_PUBLIC_API_URL
? `${process.env.NEXT_PUBLIC_API_URL}/worker/:path*`
: 'http://localhost:8787/worker/:path*',
: "http://localhost:8787/worker/:path*",
},
]
];
},
}
};

for (const plugin of plugins) {
config = {
...config,
...plugin(config),
}
};
}

const millionConfig = {
auto: true,
mute: true,
}
};

if (enableMillionJS) {
config = million.next(config, millionConfig)
config = million.next(config, millionConfig);
}

if (enablePattyCake) {
config = pattycake.next(config)
config = pattycake.next(config);
}

return config
}
return config;
};
10 changes: 7 additions & 3 deletions apps/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,29 @@
"dependencies": {
"@cloudflare/next-on-pages": "1.8.3",
"@ducanh2912/next-pwa": "^9.7.2",
"@fullhuman/postcss-purgecss": "^5.0.0",
"@supabase/auth-helpers-nextjs": "^0.7.4",
"@supabase/auth-helpers-react": "^0.4.2",
"@t4/ui": "workspace:*",
"@tamagui/next-theme": "1.75.9",
"@tamagui/next-theme": "1.88.18",
"@tsndr/cloudflare-worker-jwt": "2.2.7",
"app": "workspace:*",
"million": "2.6.4",
"next": "14.0.1",
"next-seo": "^6.4.0",
"next-superjson-plugin": "^0.5.10",
"pattycake": "^0.0.2",
"postcss": "^8.4.33",
"postcss-flexbugs-fixes": "^5.0.2",
"postcss-preset-env": "^9.3.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-native": "^0.72.6",
"react-native-web-lite": "1.75.9",
"react-native-web": "^0.19.10",
"webpack": "^5.88.2"
},
"devDependencies": {
"@tamagui/next-plugin": "1.75.9",
"@tamagui/next-plugin": "1.88.18",
"@types/react": "^18.2.37",
"vercel": "33.0.2",
"wrangler": "3.22.3"
Expand Down
29 changes: 29 additions & 0 deletions apps/next/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = {
plugins: [
'postcss-flexbugs-fixes',
[
'postcss-preset-env',
{
autoprefixer: {
flexbox: 'no-2009',
},
stage: 3,
features: {
'custom-properties': false,
},
},
],
// [
// '@fullhuman/postcss-purgecss',
// {
// content: [
// './pages/**/*.{js,jsx,ts,tsx}',
// './../../packages/app/**/*.{js,jsx,ts,tsx}',
// './../../packages/ui/**/*.{js,jsx,ts,tsx}',
// ],
// defaultExtractor: (content) => content.match(/[\w-/:]+(?<!:)/g) || [],
// safelist: ['html', 'body'],
// },
// ],
],
}
12 changes: 6 additions & 6 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
"@shopify/flash-list": "^1.6.3",
"@t4/api": "workspace:*",
"@t4/ui": "workspace:*",
"@tamagui/animations-react-native": "1.75.9",
"@tamagui/colors": "1.75.9",
"@tamagui/font-inter": "1.75.9",
"@tamagui/lucide-icons": "1.75.9",
"@tamagui/shorthands": "1.75.9",
"@tamagui/themes": "1.75.9",
"@tamagui/animations-react-native": "1.88.18",
"@tamagui/colors": "1.88.18",
"@tamagui/font-inter": "1.88.18",
"@tamagui/lucide-icons": "1.88.18",
"@tamagui/shorthands": "1.88.18",
"@tamagui/themes": "1.88.18",
"@tanstack/react-query": "^4.36.1",
"@trpc/client": "^10.43.2",
"@trpc/next": "^10.43.2",
Expand Down
17 changes: 9 additions & 8 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@
"@shopify/flash-list": "^1.6.3",
"@supabase/supabase-js": "^2.38.4",
"@t4/api": "workspace:*",
"@tamagui/animations-react-native": "1.75.9",
"@tamagui/font-inter": "1.75.9",
"@tamagui/react-native-media-driver": "1.75.9",
"@tamagui/shorthands": "1.75.9",
"@tamagui/themes": "1.75.9",
"@tamagui/toast": "1.75.9",
"@tamagui/animations-react-native": "1.88.18",
"@tamagui/font-inter": "1.88.18",
"@tamagui/react-native-media-driver": "1.88.18",
"@tamagui/shorthands": "1.88.18",
"@tamagui/theme-builder": "1.88.18",
"@tamagui/themes": "1.88.18",
"@tamagui/toast": "1.88.18",
"@tanstack/react-virtual": "3.0.0-beta.68",
"jotai": "^2.5.1",
"tamagui": "1.75.9"
"tamagui": "1.88.18"
},
"devDependencies": {
"@tamagui/build": "1.75.9"
"@tamagui/build": "1.88.18"
}
}
Loading

1 comment on commit 8a957a0

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔ EAS production build completed

  • 🤖 Android build failed ❌
  • 🍏 IOS build failed ❌
Android QR IOS QR

Please sign in to comment.