I have an application, which uses socket.io, and when I try to build the app, it says:
failed to open file file:/socket.io/socket.io.js JavaException:
java.io.FileNotFoundException: /socket.io/socket.io.js (No such file or directory)
I use node.js as a back-end, so I do steal('/socket.io/socket.io.js') on the client side. I am guessing steal/buildjs, which I'm using, is trying to get socket.io.js into a production.js. How can I exclude it from the build?
Thanks.
You don't put socket.io.js into your build. It has to be included from your nodejs server via it's own script tag. Put the tag in your app's HTML file.
Alternatively, you can load it dynamically like this:
$.getScript('//yoursocketio.server/socket.io/socket.io.js',function() {
io.connect('yoursocketio.server').etc();
});
But you should never steal it.
Related
I have created the project using npx create-react-app my-app https://github.com/facebook/create-react-app.
When running npm run build I get the following:
70.28 KB build\static\js\2.93539f7c.chunk.js
22.82 KB build\static\css\main.cfe0ffe9.chunk.css
1.41 KB (+44 B) build\static\js\main.79f4d9a1.chunk.js 761 B build\static\js\runtime~main.fdfcfda2.js
The project was built assuming it is hosted at the server root. You
can control this with the homepage field in your package.json. For
example, add this to build it for GitHub Pages:
Looks like I need to have server to run the app.
Is it possible to run this locally without any server running? I mean since it is just html,css,js and why would a server be needed here? for what purpose?
Also there is many files generated into the build folder, there is an index.html too, a static folder, so its not like a single bundle.js and a single index.html, it seems more complicated.
Anyone can explain why the build folder is this much files? and which one to consider for running the app?
Thanks
Is it possible to run this locally without any server running?
No
I mean since it is just html,css,js and why would a server be needed here? for what purpose?
React loads content using XHR, which can't make requests to file scheme URLs.
Anyone can explain why the build folder is this much files?
React makes use of code chunking to optimise which data is loaded. This means that JS which isn't used immediately can be loaded later on and not impact the time between initial page load and first render.
By default, Create React App produces a build assuming your app is hosted at the server root.
To override this, specify the homepage in your package.json, for example:
"homepage": "http://mywebsite.com/relativepath"
This will let Create React App correctly infer the root path to use in the generated HTML file.
source: https://create-react-app.dev/docs/deployment/#building-for-relative-paths
So you should just specify your homepage as the current path:
"homepage": "./"
I have been trying to run a Angular JS application which is located in HANA. Since the Web IDE does not support Angular JS development, I have the application in Webstorm editor locally in my laptop.I am using a Resource override plug in to direct the location of my files towards local files. However when I run the index.html from the HANA server, I am getting HTTP 404 error.
Please verify that you have two files in the folder to allow web access:
.xsaccess see content guide here
.xsapp (empty file)
I have an ember app that works by itself, I am able to run the server and see it. I then ran ember build, and opened up the /dist/index.html in my browser. I was unable to load any css or js in the /dist/assets folder, and it was instead looking at my root filesystem. I opened up index.html and commented out the <base href='/'>. After doing that I was able to load the css, and js. However, I am getting a security issue. What am I doing wrong with this build process, and should I have to comment out <base href='/'>?
The security issue I got was Uncaught SecurityError: Failed to execute 'replaceState' on 'History': A history state object with URL
If you open a modern SPA's starting html directly with its file://... in a browser, it will almost never work. Browsers treat files opened from the local file system different then html sent by a server.
So what you should do is always use a webserver to deploy your files to your browser. In a typical ember app you should also deploy the app to the root folder, and configure your webserver to always sent the index.html out if no other file matches the requested path, so that the ember router can start doing its own routing.
This can be done in almost every webserver, like apache, nginx, IIS, and anything else. But how to do this on a special webserver is a question not about ember but about that webserver.
right now I'm running an ember-cli application on heroku by serving it with the ember server command (not sure if this is the best method) and I'd like to integrate it with New Relic, but I have no idea how to do it.
Careful, ember server starts a live-reload server for development purposes — you edit a file, save it, and the application gets rebuild in an instant — you should not use it to serve an Ember app in production, it's a potential security risk. Normally you run ember server only on your local computer where you develop the code.
For production, build your app with ember build --environment=production, that will create a set of static files in your project's dist/ directory. You can upload these as you would upload any HTML/CSS/Javascript.
Keep in mind that Ember (and other frameworks of this kind like Angular and Backbone) is a single page application (SPA) framework; there is no server-side code at all, it all runs in the browser. Usually you would provide some sort of API (like a REST-API) on the server to provide and process data from a database or to provide other server-side services. That way you can develop the front and back-end separately.
I'm not too familiar with New Relic, but as far as I can tell it is analytics software that runs on the back-end, so it has nothing to do with your browser-side framework.
At the server folder, just find the index.js file and add require('newrelic'); at the beginning of the file. Of course you should also follow the instructions when you setup New Relic at you Heroku App, setting your application as a node.js app, which means you'll have to run npm install --save newrelic, go to your node_modules folder, find newrelic, copy newrelic.js file to the root of your application and edit the file with your app_name and license_key.
I recently removed my code from <meta ... in app/index.html and started to use this addon Ember-new-relic.
Get the JavaScript snippet.
And add it below <meta http-equiv="X-UA-Compatible"... in app/index.html.
I've been working on an app which will feature a Timelinejs (open source js library) element on the client side. I copied the Timelinejs library into my public/javascripts/ directory of my app. Then I linked it in my html header. When I serve my app up locally everything works fine with the timeline. However, I noticed that when I deployed my app to Heroku it wasn't loading my timeline. Using chrome js console I discovered that it didn't find my files in the public/Javascripts/Timelinejs folder. Using the Heroku run bash command I discovered that none of my Timelinejs files were present in the file structure, although an empty Timelinejs directory was present. Is there any command or configuration I need to specify to get these files to my Heroku deployment?
Heroku has a readonly file system. The directory where you can write are ./tmp or ./log. You can't write inside the public folder.
That's because of how they manage their dynos and the way to scale them. If you want to store something, use the ./tmp or, recommended, a s3 bucket. (as I presume 'tmp' stands for 'temporary' :D)
More info here: https://devcenter.heroku.com/articles/read-only-filesystem