Configure CRA-generated app to NOT download Workbox from CDN, but a local copy - create-react-app

I am looking for a recommendation on configuring my CRA-generated app's generated Workbox service-worker.js to fetch the Workbox library from my main app bundle's workbox library, so that the app does not need to depend on Google's CDN. By default, the CRA app loads workbox from the Google CDN.
Specifically, I want the generated line importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js"); inside the generated serice-worker.js file to be replaced.
There seem to be no elegant solutions to configuring this, and I would be super appreciative if someone could guide me forward. Thanks!

I would recommend using create-react-app v4, along with the cra-template-pwa.
That will give you a Workbox-based service worker that is self-contained and does not depend on loading anything from the CDN.
Earlier versions of c-r-a unfortunately are not customizable in this regard.

Related

How make changes on vue project in hosting

I have vue project which published on Digital Ocean. The main problem is when i make some changes on FileZilla it is not affect on website. How can i solve this issue?
This is not an issue per-se. This is just the way how modern web development works. Vue.js (but also Nuxt) is using a bundler right now (Webpack, Vite are the most common), hence to go to production it needs to be bundled each time you push something to it.
If you upload something via FTP or SSH and edit some source code, a bundle step will be required in order to get any changes on the actual webapp.
Backend languages may not need that, for example you could SSH into a server and change some .php file, if you F5 the page it will be updated in real time. But this is not how frontend JS code works, it needs to be optimised.
Another thing, sending code via SSH/FTP is not really a good workflow because it is not easily trackable, no version-controlled, will not trigger any build flags in case of an error etc...
The best approach is to have a git repo + some build step included in some CI.
A common platform for it is Netlify, you connect a Github repo, you tell which command to use to build the project and each time you push some code, it may do some checks/tests/optimizations/etc... via Github Actions before being released automatically to production (updated on your webapp).
This workflow have a lot of benefits as one may tell but is also de-facto, the official/regular approach for modern Web development on the frontend.

Is it possible to integrate Webpack/VueJS with the Odoo Framework (v12)?

I'd like to integrate VueJS through WebPack in one of my custom Odoo modules, and have it start up automatically when I launch Odoo-bin.
Does anyone have a solution?
Is it even possible?
I know you can include VueJS as a simple .JS file in the module's template, but that means I can't use the .vue components supported by WebPack.
I also read that Odoo has its own JS framework, but I couldn't find good tutorials/documentation for it.
EDIT: To anyone that might be wondering how I solved this, here's what I did:
I initialized a package.json file in the root of my Odoo folder using npm init. I added a start script to the package that launches webpack and bundles all vue components in myAddons folder (where I store my custom modules), then launches Odoo through the python odoo-bin ... command. All that's left is to use npm start to start it all up.
This way, the vue components get bundled into single JS files, that I then add to the templates of my modules. This has a small inconvenient in that the first bundle has to be done manually in order to know which JS files need to be imported to the templates. Also, i'm still trying to figure out how to bundle the components of every single module separately. Will update this once I find a proper way to do it. ...Hopefully.
By default, odoo frontend part is heavily built upon backbone, jquery, underscore. If you want to use any other JS library, you have to make sure the compatibility in between them. The odoo backend parts of JS functionalities are written under web module can be found in odoo/addons/web/static/src/js directory in odoo community codes. The ecommerce/website part is under website* modules.
Along with the fact that the Odoo JS API documentation is basically non-existent (as of the time I am posting this) .. I would add the fact that its going to be like working with a moving target compared to calling Odoo's JSON-RPC API directly since their JSON-RPC API changes very little over different versions of Odoo.
Moreover, making JSON-RPC API calls with Axios is extremely simple. So just go directly to the server's JSON-RPC API from your Vue project.
This is what I am doing with at odooinvue.org which is basically a Vue project that uses Odoo in the back-end. That project is designed specifically as a resource for Vue developers that are trying to use Odoo in the back-end but have difficulty because they are new to Odoo development.
I suggest trying #StartupGuy's odooinvue, which is really nice.
With Odoo 14 they created a new modern frontend framework: Owl framework.
I have not tried it myself.

Integrating Polymer application with ExpressJS application

I use ExpressJS to build an application and after trying different frontend frameworks (vue and angular) I settled on google Polymer. I integrated the polymer app by including all the Polymer files in the Expressjs public folder (every file including package.json) and it works fine with my api routes.
Now my question is regarding this approach:
1-Is it safe to include it in the expressjs public folder? It's just html, css and js files.
2-If there is a better setup. What would be a better setup?
I hope someone out there with good experience and enough knowledge could share some practical advice with me. Please be a little specific and if you can share an application folder structure so I can understand it visually.
Yes, it should be safe, because Polymer is a client-side Framework, which means that all of its files have to be public anyway, but usually you serve the build-version of your project (Run "polymer build" with the options you need), which doesn't contain all the config-files (like package.json).

Bootstrapping Aurelia

Finally, I start to work with Aurelia. There is a starter kit available Here which facilitates initializing Aurelia. But it is a template which should be used within a Web Site template.
I have a pre-configured WebApi project and I want to use Aurelia in it. I've just added the starter kit files and folders to my project. But unfortunately it shows 27651 errors fo files in jspm_packages.
What am I doing wrong? Is there any Nuget bootstrapper for Aurelia available?
Start with the aspnetcore template from Here
You can use web api from the template.
You will be up and running in minutes.
If you are using Web API, starting from an MVC5 project might be faster.
The following link is an Aurelia starter kit with MVC5.
You will have to update it to the latest version of Aurelia, but I managed to make it work with web api 2 and oAuth authentication.
https://github.com/rmourato/Mvc5-Aurelia
A tutorial can be found here.
http://ruimourato.com/2016/01/26/running-aurelia-on-mvc5.html
Hope this helps.
Well you asked what the errors are from. First thing is that you should exclude the jspm_packages folder from VisualStudios solution explorer Right click on it and mark 'exclude from project'.
Next, setup your project on source control (git) if not already and add the following to your git .ignore file
jspm_packages/
node_modules/`
I would suggest creating a second project aside from your WebAPI project that can contain static html, css and js files and do your Aurelia application there separate from your Web API project but in the same solution.
I could possibly give you a solution that is already setup, that shows how to use web api along with aurelia. But it would take some time for me to setup.
For all of my projects using Aurelia, I use the aurelia-cli which you get through npm and I would also recommend this approach.
You can be up and running with hello world in under 5 minutes.
You will then be able to build all the appropriate bits and pieces to talk to your api.
http://aurelia.io/hub.html#/doc/article/aurelia/framework/latest/the-aurelia-cli/1

Loading dependencies from node_modules in Angular 2 for hosted apps

I wanted start with the new Angular 2 but I can't grasp how npm is used in the official (and several other) tutorials. For me the node_modules directory is mainly used for development but in index.html the needed script files are mostly included from this location:
<script src="node_modules/systemjs/dist/system.src.js"></script>
When hosting the app on your own machine, there seems to be no problem because everything would be present due to npm install. But if I want to host my app somewhere else (e.g. as a Github Page) I generally don't have node_modules as it would be excluded in .gitignore.
One way would be to load the dependencies via some CDN but is there a better solution?
as you know node_modules are mainly used for development purpose, you dont need them in your repo while hosting your code.
You can follow two approaches here.
Deploy as it is. Just that - no minification, concatenation, name mangling etc.copy all your node_modules,Transpile all your ts project, copy all your resulting js/css/... to the hosting server and you can host your app.
second approach will be the recommended one.Deploy using special bundling tools. Like webpack or systemjs builder.basically these builder will make a bundle of your application, and you can just deploy that bundle on the server.
For more reference, I have provided links of sample apps:
Webpack Starter
SystemJS builder
Hoe this helps.