Gathering detailed insights and metrics for react-native-typed-postcss-transformer
Gathering detailed insights and metrics for react-native-typed-postcss-transformer
Gathering detailed insights and metrics for react-native-typed-postcss-transformer
Gathering detailed insights and metrics for react-native-typed-postcss-transformer
PostCSS transformer with Typescript support for React Native
npm install react-native-typed-postcss-transformer
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
1 Stars
47 Commits
2 Watchers
6 Branches
1 Contributors
Updated on May 27, 2025
Latest Version
0.20.9
Package Id
react-native-typed-postcss-transformer@0.20.9
Unpacked Size
9.96 kB
Size
3.66 kB
File Count
4
NPM Version
6.14.12
Node Version
12.22.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Use PostCSS to transform CSS to react native style objects.
This transformer also generates .d.ts
Typescript typings for the CSS files. Notice that platform specific extensions are not supported in the Typescript typings.
This transformer can be used together with React Native CSS modules.
Minimum React Native version for this transformer is 0.52. If you are using an older version, please update to a newer React Native version before trying to use this transformer.
1yarn add --dev react-native-typed-postcss-transformer postcss
Add your PostCSS configuration to one of the supported config formats, e.g. package.json
, .postcssrc
, postcss.config.js
, etc.
Add this to metro.config.js
in your project's root (create the file if it does not exist already):
1const { getDefaultConfig } = require("metro-config"); 2 3module.exports = (async () => { 4 const { 5 resolver: { sourceExts } 6 } = await getDefaultConfig(); 7 return { 8 transformer: { 9 babelTransformerPath: require.resolve("./postcss-transformer.js") 10 }, 11 resolver: { 12 sourceExts: [...sourceExts, "css", "pcss"] 13 } 14 }; 15})();
If you are using Expo, you also need to add this to app.json
:
1{ 2 "expo": { 3 "packagerOpts": { 4 "config": "metro.config.js", 5 "sourceExts": ["ts", "tsx", "css", "pcss"] 6 } 7 } 8}
If you are using React Native without Expo, add this to rn-cli.config.js
in your project's root (create the file if you don't have one already):
1module.exports = { 2 getTransformModulePath() { 3 return require.resolve("./postcss-transformer.js"); 4 }, 5 getSourceExts() { 6 return ["ts", "tsx", "css", "pcss"]; // <-- Add other extensions if needed. 7 } 8};
If you are using Expo, instead of adding the rn-cli.config.js
file, you need to add this to app.json
:
1{ 2 "expo": { 3 "packagerOpts": { 4 "sourceExts": ["ts", "tsx", "css", "pcss"], 5 "transformer": "./postcss-transformer.js" 6 } 7 } 8}
Create postcss-transformer.js
file to your project's root and specify supported extensions:
1// For React Native version 0.59 or later 2var upstreamTransformer = require("metro-react-native-babel-transformer"); 3 4// For React Native version 0.56-0.58 5// var upstreamTransformer = require("metro/src/reactNativeTransformer"); 6 7// For React Native version 0.52-0.55 8// var upstreamTransformer = require("metro/src/transformer"); 9 10// For React Native version 0.47-0.51 11// var upstreamTransformer = require("metro-bundler/src/transformer"); 12 13// For React Native version 0.46 14// var upstreamTransformer = require("metro-bundler/build/transformer"); 15 16var postcssTransformer = require("react-native-typed-postcss-transformer"); 17var postCSSExtensions = ["css", "pcss"]; // <-- Add other extensions if needed. 18 19module.exports.transform = function({ src, filename, options }) { 20 if (postCSSExtensions.some(ext => filename.endsWith("." + ext))) { 21 return postcssTransformer.transform({ src, filename, options }); 22 } 23 return upstreamTransformer.transform({ src, filename, options }); 24};
Your App.css
file might look like this (using postcss-css-variables plugin):
1:root { 2 --blue-color: blue; 3} 4 5.myClass { 6 color: var(--blue-color); 7} 8.myOtherClass { 9 color: red; 10}
When you import your stylesheet:
1import styles from "./App.css";
Your imported styles will look like this:
1var styles = { 2 myClass: { 3 color: "blue" 4 }, 5 myOtherClass: { 6 color: "red" 7 } 8};
The generated App.css.d.ts
file looks like this:
1export const myClass: string; 2export const myOtherClass: string;
You can then use that style object with an element:
1<MyElement style={styles.myClass} />
rn-cli.config.js
to a project, https://github.com/kristerkari/react-native-postcss-transformer/issues/1.No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/23 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
24 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More