Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use postcss to extract styles in Expo example #239

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/examples/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
"backgroundColor": "#ffffff"
},
"assetBundlePatterns": ["**/*"],
"ios": {
"supportsTablet": true
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#ffffff"
}
},
"ios": {
"supportsTablet": true
},
"web": {
"bundler": "metro",
"favicon": "./assets/favicon.png"
Expand Down
7 changes: 2 additions & 5 deletions apps/examples/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,13 @@ module.exports = function (api) {
//api.cache(true);

const platform = api.caller(getPlatform);
const isDev = api.caller(getIsDev);
const dev = api.caller(getIsDev);

const presets = ['babel-preset-expo'];
const plugins = [];

if (platform === 'web') {
presets.push([
reactStrictPreset,
{ debug: true, dev: isDev, rootDir: __dirname }
]);
presets.push([reactStrictPreset, { debug: true, dev, rootDir: __dirname }]);
}

return {
Expand Down
8 changes: 5 additions & 3 deletions apps/examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"private": true,
"name": "examples",
"version": "0.0.0",
"main": "./src/index.js",
"main": "./src/app/index.js",
"scripts": {
"dev": "expo start --clear",
"dev:android": "expo start --android --clear",
Expand All @@ -11,13 +11,15 @@
},
"dependencies": {
"@expo/metro-runtime": "~4.0.0",
"expo": "^52.0.3",
"expo": "^52.0.6",
"expo-build-properties": "~0.13.1",
"expo-status-bar": "~2.0.0",
"postcss-react-strict-dom": "^0.0.5",
"react": "~18.3.1",
"react-dom": "~18.3.1",
"react-native": "~0.76.1",
"react-native-web": "~0.19.13"
"react-native-web": "~0.19.13",
"react-strict-dom": "*"
},
"devDependencies": {
"@babel/core": "^7.25.2"
Expand Down
18 changes: 18 additions & 0 deletions apps/examples/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

module.exports = {
plugins: {
'postcss-react-strict-dom': {
include: [
require.resolve('react-strict-dom'),
necolas marked this conversation as resolved.
Show resolved Hide resolved
'src/**/*.{js,jsx,mjs,ts,tsx}'
]
},
autoprefixer: {}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
* LICENSE file in the root directory of this source tree.
*/

import { LogBox } from 'react-native';
// Required to apply extracted on Expo Web
import './stylex.css';
// Required for Fast Refresh to work on Expo Web
import '@expo/metro-runtime';

import { LogBox } from 'react-native';
import { registerRootComponent } from 'expo';

import App from './App';
import App from '../components/App';

if (LogBox != null) {
LogBox.ignoreLogs([
Expand Down
13 changes: 13 additions & 0 deletions apps/examples/src/app/stylex.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* The @stylex directive is used by the react-strict-dom postcss plugin.
* It is automatically replaced with generated CSS during builds.
*/

@stylex;
File renamed without changes.
Loading