@callstack/repack-plugin-nativewind
Version:
A plugin for @callstack/repack that integrates NativeWind
29 lines (28 loc) • 1.02 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.raw = void 0;
exports.default = nativeWindLoader;
const dedent_1 = __importDefault(require("dedent"));
const css_to_rn_1 = require("react-native-css-interop/css-to-rn");
const utils_js_1 = require("./utils.js");
exports.raw = false;
function nativeWindLoader(source) {
this.cacheable();
const callback = this.async();
try {
const options = this.getOptions();
const jsCss = (0, css_to_rn_1.cssToReactNativeRuntime)(source, options);
const code = (0, dedent_1.default) `
import { StyleSheet } from "nativewind";
StyleSheet.registerCompiled((${(0, utils_js_1.stringify)(jsCss)}));
`;
callback(null, code);
}
catch (error) {
console.log(`Failed to convert ${this.resourcePath} to JS`, error);
callback(error);
}
}