diff --git a/examples/one-tailwind/app/base.css b/examples/one-tailwind/app/base.css
index bd6213e1d..b5c61c956 100644
--- a/examples/one-tailwind/app/base.css
+++ b/examples/one-tailwind/app/base.css
@@ -1,3 +1,3 @@
@tailwind base;
@tailwind components;
-@tailwind utilities;
\ No newline at end of file
+@tailwind utilities;
diff --git a/examples/one-tailwind/app/index.tsx b/examples/one-tailwind/app/index.tsx
index 0468fc9ea..393175b4f 100644
--- a/examples/one-tailwind/app/index.tsx
+++ b/examples/one-tailwind/app/index.tsx
@@ -3,9 +3,9 @@ import { Text, View } from 'react-native'
import './base.css'
export default function Index() {
- const out = (
-
this is bg should be red by tailwind
- )
+ // const out = (
+ // this is bg should be red by tailwind
+ // )
console.log('what is', typeof out.props.children, typeof out.props.children?.props)
@@ -19,11 +19,11 @@ export default function Index() {
minHeight: '100%',
}}
>
- Hello world, from One
+ {/* Hello world, from One
- {/* */}
+ */}
- {out}
+ {/* {out} */}
)
}
diff --git a/examples/one-tailwind/tailwind.config.js b/examples/one-tailwind/tailwind.config.js
index 9a0b4bec1..8642884af 100644
--- a/examples/one-tailwind/tailwind.config.js
+++ b/examples/one-tailwind/tailwind.config.js
@@ -1,12 +1,9 @@
/** @type {import('tailwindcss').Config} */
export default {
- content: [
- "./index.html",
- "./src/**/*.{js,ts,jsx,tsx}",
- "./app/**/*.{js,ts,jsx,tsx}",
- ],
+ content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}', './app/**/*.{js,ts,jsx,tsx}'],
theme: {
extend: {},
},
- plugins: [require("tailwindcss-animate"), require("tailwindcss-motion")],
-};
+ resets: [require('nativewind/preset')],
+ plugins: [require('tailwindcss-animate'), require('tailwindcss-motion')],
+}
diff --git a/packages/compiler/src/index.ts b/packages/compiler/src/index.ts
index bac397a7f..6ecbc8406 100644
--- a/packages/compiler/src/index.ts
+++ b/packages/compiler/src/index.ts
@@ -12,6 +12,8 @@ import { debug, runtimePublicPath, validParsers } from './constants'
import { getBabelOptions, transformBabel } from './transformBabel'
import { transformSWC } from './transformSWC'
import type { Environment, GetTransformProps, Options } from './types'
+import { cssToReactNativeRuntime } from 'react-native-css-interop/css-to-rn/index.js'
+import { configuration } from './configure'
export * from './configure'
export * from './transformBabel'
@@ -51,6 +53,23 @@ export async function createVXRNCompilerPlugin(
: undefined,
},
+ {
+ name: `one:compiler-css-to-js`,
+ enforce: 'post',
+ transform(code, id) {
+ const environment = getEnvName(this.environment.name)
+ if (configuration.enableNativeCSS && (environment === 'ios' || environment === 'android')) {
+ if (extname(id) === '.css') {
+ const data = JSON.stringify(cssToReactNativeRuntime(code, { inlineRem: 16 }))
+ return {
+ code: `require("nativewind").StyleSheet.registerCompiled(${data})`,
+ map: null,
+ }
+ }
+ }
+ },
+ },
+
{
name: 'one:compiler',
enforce: 'pre',
@@ -61,6 +80,10 @@ export async function createVXRNCompilerPlugin(
optimizeDeps: {
noDiscovery: true,
},
+
+ define: {
+ 'process.env.NATIVEWIND_OS': 'native',
+ },
} satisfies UserConfig
return {
@@ -93,10 +116,8 @@ export async function createVXRNCompilerPlugin(
const production = process.env.NODE_ENV === 'production'
if (extension === '.css') {
- console.warn('EXTENSION CSS')
- if (environment === 'ios' || environment === 'android') {
- return null
- }
+ // handled in separate post plugin
+ return
}
let id = _id.split('?')[0]
diff --git a/packages/compiler/src/transformSWC.ts b/packages/compiler/src/transformSWC.ts
index e0f3dae02..48a4c7d91 100644
--- a/packages/compiler/src/transformSWC.ts
+++ b/packages/compiler/src/transformSWC.ts
@@ -37,9 +37,8 @@ export async function transformSWC(
return
}
- const enableNativeCSS =
- configuration.enableNativeCSS &&
- (options.environment === 'ios' || options.environment === 'android')
+ const enableNativeCSS = configuration.enableNativeCSS
+
// temp fix idk why this error:
// node_modules/react-native-reanimated/src/component/LayoutAnimationConfig.tsx (19:9): "createInteropElement" is not exported by "../../node_modules/react-native-css-interop/dist/runtime/jsx-dev-runtime.js", imported by "node_modules/react-native-reanimated/src/component/LayoutAnimationConfig.tsx
!id.includes('node_modules')
diff --git a/packages/compiler/types/transformSWC.d.ts b/packages/compiler/types/transformSWC.d.ts
index 512803e2a..995e56a4e 100644
--- a/packages/compiler/types/transformSWC.d.ts
+++ b/packages/compiler/types/transformSWC.d.ts
@@ -2,6 +2,8 @@ import { type Output, type Options as SWCOptions } from '@swc/core';
import type { Options } from './types';
export declare function transformSWC(id: string, code: string, options: Options & {
es5?: boolean;
-}, swcOptions?: SWCOptions): Promise