React Native 打包.jsx文件
最近在研究React Native。感觉开发效率确实不错,但jsx语法写起来感觉不怎么顺手。
试用了Sublime Text 3和Visual Studio Code写代码,感觉反应总是慢一拍。
还是想换回VS2015写jsx,但用VS写jsx好像只能在后缀为.jsx的文件里面写。(不知道VS有没有直接设置在js里写jsx的方法)
于是翻了下react-native的打包程序,改了下让打包程序能自动打包.jsx文件。
贴出修改方法,习惯能VS的可以试着改下
1.项目主文件夹\node_modules\react-native\packager\react-packager\src\Server\index.js
找"var watchRootConfigs = opts.projectRoots.map(dir => {"这段,加上'.jsx'
var watchRootConfigs = opts.projectRoots.map(dir => {
return {
dir: dir,
globs: [
'**/*.js',
'**/*.json',
'**/*.jsx',
].concat(assetGlobs),
};
});
2.项目主文件夹\node_modules\react-native\packager\react-packager\src\DependencyResolver\DependencyGraph\index
0.22版使用的是node-haste在\node_modules\react-native\node_modules\node-haste\lib\index
找"this._crawling = crawl(allRoots, {"加段,同样加上'jsx'
this._crawling = crawl(allRoots, {
ignore: this._opts.ignoreFilePath,
exts: ['js', 'jsx','json'].concat(this._opts.assetExts),
fileWatcher: this._opts.fileWatcher,
});
3.项目主文件夹\node_modules\react-native\packager\react-packager\src\DependencyResolver\DependencyGraph\ResolutionRequest.js
0.22版在\node_modules\react-native\node_modules\node-haste\lib\DependencyGraph
找"if (this._fastfs.fileExists(potentialModulePath)) {"改成
let file;
let exts=["",
this._platform?('.' + this._platform + '.js'):null,
'.js',
'.json',
'.jsx'];
for(let c=0;c<exts.length;c++){
if(null!=exts[c]
&&this._fastfs.fileExists(potentialModulePath + exts[c])
&&(file = potentialModulePath + exts[c]))
break;
}
if(!file){
throw new UnableToResolveError(
fromModule,
toModule,
`File ${potentialModulePath} doesnt exist`,
);
}
//以下为原来的代码
//if (this._fastfs.fileExists(potentialModulePath)) {
// file = potentialModulePath;
//} else if (this._platform != null &&
// this._fastfs.fileExists(potentialModulePath + '.' + this._platform + '.js')) {
// file = potentialModulePath + '.' + this._platform + '.js';
//} else if (this._fastfs.fileExists(potentialModulePath + '.js')) {
// file = potentialModulePath + '.js';
//} else if (this._fastfs.fileExists(potentialModulePath + '.json')) {
// file = potentialModulePath + '.json';
//} else {
// throw new UnableToResolveError(
// fromModule,
// toModule,
// `File ${potentialModulePath} doesnt exist`,
// );
//}
改成后再运行 react-native start就可以自动打包后缀为.jsx的文件了。
React Native 打包.jsx文件的更多相关文章
- [RN] React Native 打包时 减少 Apk 的大小
React Native 打包时 减少 Apk 的大小 主要有两个方法: 在打包前设置 android\app\build.gradle 文件中 1) def enableProguardInRele ...
- React Native之APK文件签名及打包
生成apk签名文件 我们使用android studio的方式进行签名 AS工具栏找到并点击 build->gennrate signed apk 两种情况: 1.这里如果已经有签名文件了则直接 ...
- react native 之上传文件
最近遇到react native中需要上传一些图片到后台.期间,找了一些第三方上传插件,感觉不太好用,要么只支持一个平台,要么会对其他第三方造成影响,实在无奈.只能直接使用fetch上传.其中上传文件 ...
- react native 打包至iphone设备
1.新建bundle 在自己项目的ios文件夹下新建一个文件夹取名bundle PS:ios文件夹和node_modules文件夹在同一级目录下,这个bundle文件夹名称随意取,后面要用到,但是记得 ...
- React Native 打包 Apk
第一步:生成秘钥库 keytool -genkey -v -keystore opsmart-android-release-key.keystore -alias opsmart-android - ...
- react native 的js 文件从哪里获取
/** * Loading JavaScript code - uncomment the one you want. * * OPTION 1 * Load from development ser ...
- react native 打包上架
https://www.jianshu.com/p/ce71b4a8a246 react-native bundle --entry-file index.ios.js --platform ios ...
- react native 打包Ignoring return value of function declared with warn_unused_result attribute
从 github上下载 项目 用于学习查看别人的代码, 当执行完npm install 用xcode 打开 发现俩个错误提示Ignoring return value of function dec ...
- [React Native] 解析JSON文件
在编写代码时,开发者有时需要存储一些比较多,在应用程序运行时不需要更改的数据.文件大不便于写在代码中,可以把这些数据存储到JSON文件中. 优点非常明显: 1. 数据存放在单独的文件中,代码精简有条理 ...
随机推荐
- sql语句错误
此错误一般有以下情况造成: 1.配置文件中SQL语句写的有问题 2.传参过程中没有找到sql对应的参数 解决方法: 1.检查sql语句 2.debug启动,查找与sql语句相对应的参数是否存在. 3. ...
- BW系统之间的InfoProvider数据传输:Export DataSource
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- [Unity] Android插件
1> 编写eclipse android代码. 2> 把unity下class.jar拷入eclipse libs目录下, 工程中右键build path, add to build pa ...
- newInstance()和new()
在Java开发特别是数据库开发中,经常会用到Class.forName( )这个方法.通过查询Java Documentation我们会发现使用Class.forName( )静态方法的目的是为了动态 ...
- Macbook Pro配置PHP开发环境
Macbook Pro配置PHP开发环境 安装环境如下: Mac OS 10.10.1 Apache 2.4.9 PHP 5.5.14 MySQL 5.6.22 Apache配置 在Mac OS 10 ...
- VR视频外包公司(长年承接虚拟全景外包、虚拟现实视频外包)
承接VR视频外包(虚拟全景外包),虚拟现实视频外包(北京公司) 我们制作各类型VR全景虚拟现实,增强现实视频制作.录制等项目! 品质保证,售后完备. 我们团队成立于2011年10月,是一个专业从事严肃 ...
- web开发字符乱码问题
java动态网页后台乱码问题总结 乱码可能出现的几块地方: 首先是浏览器和html之间采用的编码不一致 解决办法: 修改浏览器的编码格式 修改html页面的编码格式: <meta http-eq ...
- Java动态代理与Cglib库
JDK动态代理 代理模式是常用的java设计模式,他的特征是代理类与委托类有同样的接口,代理类主要负责为委托类预处理消息.过滤消息.把消息转发给委托类,以及事后处理消息等.代理类与委托类之间通常会存在 ...
- css3 文字过长用...代替
white-space: nowrap; text-overflow: ellipsis; overflow: hidden; white-space:nowrap 代表多个空格/回车不换行: tex ...
- 從 Internet 安裝 Cygwin
從 Internet 安裝 Cygwin 如果您有高速的 Internet 連線, 可以考慮用這個方法, 否則不建議使用 執行 setup.exe Cygwin Setup 畫面, 按 Next. C ...