我用create-react-app创建了一个ReactJs应用程序,然后使用了npm run build.在我用Cordova创建的www文件夹中,我只是复制create-react-app的 build文件夹中的所有文件,这很好.
我想知道如何挂钩Cordova的事件,例如:
function startApp() {
// your app logic
}
if (window.cordova) {
document.addEventListener('deviceready', startApp, false);
} else {
startApp();
}
Run Code Online (Sandbox Code Playgroud)
例如,我想在里面调用缩小的JS文件startApp().或者是否有任何其他工作流可用于使Cordova事件与react应用程序一起使用.
一个小例子会有所帮助.
是否可以使用构建文件并直接在Cordova内部使用React App?我不确定这是如何工作的,因为有Webpack设置将ES6代码转换为ES5和所有.
我是Cordova的新手,并且在这个整合方面苦苦挣扎.
在开发中,我希望能够从Web上看到构建信息(git commit hash,author,last commit message等).我试过了:
npm build并从文件中读取(不起作用,因为fs在浏览器环境中也不可用)剩下要做的唯一事情似乎是做npm run eject和应用https://www.npmjs.com/package/git-revision-webpack-plugin,但我真的不想弹出create-react-app.有人有任何想法吗?
我认为这与直接使用webpack有关,因此提供了更大的灵活性.但我不完全确定是否有人可以解释"弹射"的含义.还有什么是弹出创建反应应用程序的后果?这样做不好,或者?
我想知道如何在 create-react-app 中生成源映射?它们是隐式完成的吗?他们是否住在构建文件夹中
我已经阅读了很多关于它们是用 webpack 生成的,但我的应用程序没有使用它,所以我想知道如果没有 webpack 怎么办?
我也不想弹出
-->
create-react-app : File C:\Users\ADMIN\AppData\Roaming\npm\create-react-app.ps1 cannot be loaded because running
scripts is disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ create-react-app demo
Run Code Online (Sandbox Code Playgroud) 我真的很喜欢可以看出该文件夹结构在这里有一个前端做出反应和处理时,一些后端与快递:
root
??? backend
| ??? node_modules
| ??? public
| ??? src
? ? ??? Server.ts
| ??? package.json
| ??? tsconfig.json
??? frontend (created using create-react-app)
| ??? node_modules
| ??? public
| ??? src
? ? ??? Index.js
| ??? package.json
| ??? tsconfig.json
Run Code Online (Sandbox Code Playgroud)
我认为将单独的包与个人分开node_modules是合理的,因为前端和后端基本上是完全不同的东西,例如它们需要不同的节点模块。此外,这种模块化方法在视觉上对我很有吸引力,并且存储库看起来很整洁。
但是,当我需要在前端和后端之间共享内容时,我遇到了这种结构的问题。我shared在项目根目录下添加了一个文件夹,该文件夹包含自己的项目和自己的tsconfig.json,package.json等等。这种方法是here和here方法的混合。对于后端,这完全正常:设置了tsconfig.json适当的(使用TypeScript 项目引用和别名导入),我可以root/shared/src/myFile.ts像这样引用文件:
root
??? backend
| ??? node_modules
| ??? …Run Code Online (Sandbox Code Playgroud) 我正在试验纱线工作区 monorepo。它由一个用 创建的 TestProjectcreate-react-app和一个用创建的 SharedLib1 组成create-react-library。TestProject 从 SharedLib1 导入代码。问题是,TestProject 使用依赖于 babel-jest ^24.9.0 的 react-scripts 3.3.0,而 SharedLib1 使用依赖于 babel-jest 22.4.4 的 react-scripts-ts ^2.16.0。yarn start在 TestProject 中运行时,它抱怨:
The react-scripts package provided by Create React App requires a dependency:
"babel-jest": "^24.9.0"
Don't try to install it manually: your package manager does it automatically.
However, a different version of babel-jest was detected higher up in the tree:
/monoRepo/node_modules/babel-jest (version: 22.4.4)
Run Code Online (Sandbox Code Playgroud)
我可以通过SKIP_PREFLIGHT_CHECK=true在 TestProject 中设置或手动升级 SharedLib1 中的 react-scripts来禁用错误,但我想知道是否有更好的方法来处理这个问题。 …
我有一个被弹出的 CRA,并且最近将 Webpack 升级到版本 5,现在使用后npm run start我收到警告两次(附后),是否有任何选项可以只显示一次?我注意到在新的 CRA 项目中使用 ESLint webpack 插件时也会发生这种情况。
Compiled with warnings.
src/app/apollo/apollo.ts
Line 15:7: Unexpected console statement no-console
Line 18:21: Unexpected console statement no-console
Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.
WARNING in src/app/apollo/apollo.ts
Line 15:7: Unexpected console statement no-console
Line 18:21: Unexpected console statement no-console
webpack compiled with 1 warning
No issues found.
Run Code Online (Sandbox Code Playgroud) 我想将我的 jest 配置移出我的 package.json,我正在尝试按照此处的建议使用 --config,但出现错误argv.config.match is not a function
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --config jest.config.js",
"eject": "react-scripts eject",
},
Run Code Online (Sandbox Code Playgroud)
hutber@hutber-mac:/var/www/management/node$ npm test -u
> management-fresh@0.1.0 test /var/www/management/node
> react-scripts test --config jest.config.js
Usage: test.js [--config=<pathToConfigFile>] [TestPathPattern]
argv.config.match is not a function
npm ERR! Test failed. See above for more details.
Run Code Online (Sandbox Code Playgroud) 有没有人成功地做到了这一点?我目前已node-sass安装在我的 CRA 项目中,我正在尝试替换它,dart-sass但遇到了困难,因为 CRA 错误输出告诉我我需要node-sass安装。有什么方法可以让底层 CRA 配置知道使用我安装的dart-sass包而不是node-sass?
create-react-app ×10
reactjs ×7
javascript ×5
node.js ×3
webpack ×2
cordova ×1
eslint ×1
git ×1
jestjs ×1
monorepo ×1
node-sass ×1
sass ×1
source-maps ×1
testing ×1
typescript ×1
yarnpkg ×1