Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const importerOptions = this.options;
const incPaths = importerOptions.includePaths.slice( 0 ).split( ':' );
if ( urlPath.dir.length > 0 ) {
incPaths.unshift( path.resolve( path.dirname( filename ), urlPath.dir ) ); // add the file's dir to the search array
}
const f = findVariant( urlPath.name, exts, incPaths );
if ( f ) {
return { file: f };
}
return new Error( url + ' could not be resolved in ' + incPaths );
},
} );
const css = result.css.toString();
const cssObject = css2rn( css, { parseMediaQueries: true } );
return upstreamTransformer.transform( {
src: 'module.exports = ' + JSON.stringify( cssObject ),
filename,
options,
} );
}
return upstreamTransformer.transform( { src, filename, options } );
}
const importerOptions = this.options;
const incPaths = importerOptions.includePaths.slice( 0 ).split( ':' );
if ( urlPath.dir.length > 0 ) {
incPaths.unshift( path.resolve( path.dirname( filename ), urlPath.dir ) ); // add the file's dir to the search array
}
const f = findVariant( urlPath.name, exts, incPaths );
if ( f ) {
return { file: f };
}
return new Error( url + ' could not be resolved in ' + incPaths );
},
} );
const css = result.css.toString();
const cssObject = css2rn( css, { parseMediaQueries: true } );
return upstreamTransformer.transform( {
src: 'module.exports = ' + JSON.stringify( cssObject ),
filename,
options,
} );
}
return upstreamTransformer.transform( { src, filename, options } );
}
module.exports.transform = function(src, filename, options) {
if (typeof src === "object") {
// handle RN >= 0.46
({ src, filename, options } = src);
}
if (filename.endsWith(".css")) {
var cssObject = css2rn(src, { parseMediaQueries: true });
return upstreamTransformer.transform({
src: "module.exports = " + JSON.stringify(cssObject),
filename,
options
});
}
return upstreamTransformer.transform({ src, filename, options });
};
function getStyleObject ({css, filePath}) {
var styleObject = {}
try {
styleObject = transformCSS(css)
} catch (err) {
Util.printLog(Util.pocessTypeEnum.WARNING, 'css-to-react-native 报错', filePath)
console.log(chalk.red(err.stack))
}
return styleObject
}
function process(src) {
try {
const cssObject = css2rn(src, { parseMediaQueries: false });
return `module.exports = ${JSON.stringify(cssObject)}`;
} catch (err) {
return 'module.exports = {}';
}
}
module.exports = function(path, state, types) {
const source = path.get('quasi').evaluate().value
if (!source) {
fallback(path, state, types)
return
}
path.replaceWith(serialize(cssToRN(source, { parseMediaQueries: true })))
}
.then(result => {
var cssObject = css2rn(result.css, { parseMediaQueries: true });
return upstreamTransformer.transform({
src: "module.exports = " + JSON.stringify(cssObject),
filename,
options
});
});
});
function renderCSSToReactNative(css) {
return css2rn(css, { parseMediaQueries: true });
}
function renderCSSToReactNative(css) {
return css2rn(css, { parseMediaQueries: true });
}