How to setup mongo-migrate-ts with nx workspace - monorepo

I've created nx workspace with nest.js application. I would like to add mongo-migrate-ts support which normally was started by "ts-node migrations/index.ts up" as script in packages.json. In my nx project, when I try to add script in global package.json, it says that "ts" extension is unrecognized.

There is a typescript rewrite of the original migrate mongo, much like mongo-migrate-ts, but this one is in the form of a nx plug-in. It will work a lot better for your needs if you are using nx. It is called nx-mongo-migrate. Give it a shot!

Related

Migrate CRA project to existing Nx workspace

I have the Nx workspace with React and Express apps created via the official React tutorial from Nx docs. Also, I have an independent CRA project that has just one commit after using npx create-react-app command. I want to add my CRA project to Nx workspace preserving git histories. How can I do that?
I had read docs pages about preserving git histories and manual migration and then tried to migrate the project this way:
Migrated CRA project to a new Nx workspace automatically used npx cra-to-nx command as the docs said.
Added remote repository with initial Nx workspace.
Merged the branch that contained the new Nx workspace with the main branch from the initial Nx workspace.
To solve all the conflicts I accepted incoming changes (didn't change the configs of the initial Nx workspace).
The migration was successful but then I tried to serve or build migrated CRA app and got this error:
Where did I go wrong? Maybe I deleted some important configuration when was solving the conflicts?
This issue isn't really connected with migration from CRA to Nx. The problem was in the BUILD_PATH env that was in the yarn build script. I don't know why the BUILD_PATH isn't working this way, but when I write it in the .local.env file and not in the script, everything is fine.
The weird symbols rendered instead of the error message was the error message in russian. They are rendered correctly if I launch the yarn build script from the CRA project, not from the Nx workspace.
The migration approach that I tried to use should work, but you really don't need it. The approach from the Doing the migration manually section of CRA-to-Nx docs' page is fast and easy.

Is there any plugin similar to electron-vue for react?

Ideally, it should be able to encapsulate the electron-builder and related webpack parts, only two commands are exposed dev: electron / build: electron
But in fact, the electron-react-boilerplate template is too complicated, and did not need so many functions at first, but this template is to pile all the functions at once.
My generation found a repository https://github.com/nateshmbhat/electron-react-ts-starter, but this directly divided them completely, and did not consider the problem of code reuse. . .
Take a look at generator-react-app-electron on npm (https://www.npmjs.com/package/generator-react-app-electron).
This generator produces a non-ejected create-react-app project that is configured to run out-of-the-box with electron and a few other handy features
It provides start and build scripts that have been configured for running and building electron. Without ejecting. It also provides all essential features to develop an electron app (e.g. splash screen, entry points, ..).
Also you could use this template directly without using the generator: https://github.com/neutrinog/react-app-electron-template

Caveats of running eject on create-react-app?

I currently started a new project using create-react-app, but I'd like to add some minor custom configurations to my webpack config. (automatically address .scss files as .module.scss, etc)
As far as I learned, the only way to do that it running eject, which would allow me to configure babel\webpack myself.
I was wondering, what caveats could that have? basically, why WOULDN'T I wan't to run eject?
Thanks!
DO it, and see it for yourself, create new project in another directory and experiment with it; eject make things look a little more complicated, but it's OK, its like taking a look inside the hardware of your computer.
However if your project directory is under version control, you can reverse the eject too

How to build react.js apps at visual studio code?

I have created two apps using 'Visual Studio Code' and 'node.js.' I run them using command 'npm start,' and they show in the browser. I want to build them or deploy them so they can be used by anyone. It says there to use command 'npm run build.' How to do that, and what technique you use in order to build them?
It depends on what configuration you used for building the React app. If you used create-react-app, npm run build is the correct command for building it.
If you used a different configuration (e.g. webpack), you should use the relevant command for that configuration.
Either way, deploying it will be as easy as copy/pasting the build folder's content to the server you want to host it, after running the build command.
Visual Studio Code or any other Code Editor for that matter is not relevant. You can develop, build and deploy any React app using any Code Editor you want, it's just a matter of preference.
"Building" refers to the task of preparing (transforming, minifying, compressing, etc.) all the relevant project files so that they're ready for production (assuming that your build scripts are configured to do so).
"Deploying" an app is usually a separate task that will deploy (upload) your current project build to a development platform provider like Firebase, Netlify, Azure, etc. Note that you have to register with a provider and setup a new project on their end before your deploy your project.
Which provider you use is totally up to you. Also, you have to configure your current project once you've chosen your development provider. They'll provide instructions on how to deploy your project.
On a side note, keep in mind that you can configure your own npm scripts so that they run whatever you want. More about that here

Production Server for React Redux Starter Kit

I am using the React Redux Starter Kit from DaveZuko, and am stuck on how to create production server to serve the compile client side code.Ideally I would just like to use the Koa server and move it to production, but can't find out how to do that.
All relevant code is unchanged from the repository here: https://github.com/davezuko/react-redux-starter-kit
Does anybody know how to compile a product server for this?
I did try to use davezuko's starter kit, but it was really hard to follow what those configuration files really did and messed them up when trying to install packages that were missing.
I also tried facebook's create-react-app, but that was really complex too when you run the eject command, so I gave up and created my own starter kit http://redux-minimal.js.org/ . I has the minimum amount of packages that lets you build rich real-word apps, but doesn't have the cluttered configuration boilerplate that other starter kits have.
Now, answering your question, with redux minimal, you just do "npm run build-prod" and it compiles the css and js files for the production environment, minified and ready to go. Then you just copy the public folder which contains the html file too, paste to what ever server you want, and then call the index.html url and it works.

Resources