How to deploy reagent-frontend to Heroku? - heroku

I created a ClojureScript Reagent app from template reagent-frontend. How I can deploy production app to Heroku? After building for production (lein package / lein cljsbuild once release) leiningen generate app.js in folder public. As result public folder contain css/, js/, index.html.
On my attempt push folder public Heroku give next error:
! No default language could be detected for this app.
HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
See https://devcenter.heroku.com/articles/buildpacks
! Push failed

Heroku can serve PHP so one way to go about it is by adding an index.php file to public with the following content <?php header( 'Location: /index.html' ) ; ?> This will serve your own index.html. Then push that to Heroku.
Source: https://blog.teamtreehouse.com/deploy-static-site-heroku

Related

TS2503: Cannot find namespace 'WebDataRocks'

I have a react application and I'm trying to use WebDataRocks to render data from my bd. But, when I try to build I'm getting an error that says:
TS2503: Cannot find namespace 'WebDataRocks'.
I tried several stuff, but I still receive the error. The only things that's working is when I add a flag of ignoring the typescript type of and index.d.js. But, I can't change the modules because it's not gonna work when I send the code for prod area.
My guess is the file should be tsx not ts. But, again I can't change the modules.
Any thoughts?
I kindly suggest creating a new project and embedding WebDataRocks to check how modules should be imported.
Here is a short guide:
If you don’t have a React+TS application yet, create one by running this command in the console:
npx create-react-app my-app --template typescript
cd my-app
Get the WebDataRocks React module from npm:
npm install react-webdatarocks
Add WebDataRocks’ styles to the src/index.tsx file:
import 'webdatarocks/webdatarocks.css'
Import the WebDataRocksReact module to the src/App.tsx file:
import * as WebDataRocksReact from 'react-webdatarocks';
Open src/App.tsx and add WebDataRocks there using the WebDataRocksReact.Pivot component:
function App() {
return (
<div className="App">
<WebDataRocksReact.Pivot
toolbar={true}
componentFolder="https://cdn.webdatarocks.com/"
width="100%"
report="https://cdn.webdatarocks.com/reports/report.json"
/>
</div>
);
}
Run your application:
npm start
Open http://localhost:3000/ in the browser — WebDataRocks is embedded into your React+TS project.

Rails: application.css not in asset pipeline

I know this is a old question but no answer is fixing my problem.
I'm new to Ruby on Rails and just created project with a PostgreSQL database just to be able to upload the project to Heroku.
When i start the rails server im getting the error "application.css is not present in the asset pipeline."
I'm using bootstrap 4 gem and this requires that you rename the applications.css to application.scss.
I dont know what is wrong.
I really tried every answer that is on stackoverflow without any success :(
Please help me, what am i doing wrong?
This is the error im getting:
Ok, first thing.
Do you have config.serve_static_files = true set in your production.rb file under config/environment folder.
Since we run behind NGINX, in our case it looks like config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
Second thing. Did you do rails assets:precompile before the uploading it to the server?
And the third thing is. Have you tried calling your file application.css.scss, and redoing the rails assets:precompile?
Last, and not least thing. How does your application.scss file look like?
Did you remove all those *= and used #import instead for Bootstrap
It is nicely described in the documentation:
Import Bootstrap styles in app/assets/stylesheets/application.scss:
// Custom bootstrap variables must be set or imported before
bootstrap. #import "bootstrap";
And then it says:
Make sure the file has .scss extension (or .sass for Sass syntax). If
you have just generated a new Rails app, it may come with a .css file
instead. If this file exists, it will be served instead of Sass, so
rename it:
$ mv app/assets/stylesheets/application.css
app/assets/stylesheets/application.scss Then, remove all the *=
require and *= require_tree statements from the Sass file. Instead,
use #import to import Sass files.
Do not use *= require in Sass or your other stylesheets will not be
able to access the Bootstrap mixins and variables.
Read more here
origin answer
in my case, I forgot to install yarn command in my server.
so, please install yarn before running rails server. otherwise assets:precompile will do nothing and give no warning.
update
also, make sure all of these things:
file exists: app/assets/stylesheets/application.css
its content looks like:
/* ...
*= require_self
*= require_tree .
*/
also check file app/assets/config/manifest.js,
//= link application.css
To give more clarity to mutantkeyboard's answer
I had this issue when deploying a Rails application as a docker image that would run in a docker container without a web server like Nginx.
Here's how I got it fixed:
This issue is primarily caused in production when you do not want to serve your static files from the /public folder using a web server like Nginx or Apache.
To serve files your static files from the /public folder without using a web server like Nginx or Apache, do the following:
Ensure you precompile your assets using:
bundle exec rails assets:precompile
OR
rails assets:precompile
This will compile your assets into the /public folder
Next, in your config/environments/production.rb file, add the following:
Instead of this:
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
Use this:
config.public_file_server.enabled = true
This allows rails to serve the static files instead of a web server
Note: For improved performance it's best to serve the static files using a Web server like Apache or Nginx.
Just reinstall yarn et precompile our assets:
yarn's parkages don't push on github... to fix this, reinstall yarn:
yarn
and precompile assets:
bundle exec rails assets:precompile
Rails 7.0.4 ruby 3.1.2 I solved issue with yarn build when missing application.js but in case missing application.css just did yarn build:css

Play 2x webjars deploy to heroku failed

I tried deploying the standard angular-play-seed project, which uses angularjs and requirejs webjars to heroku.
However, on heroku it throws an error because it cannot find require.js
Failed to load resource: the server responded with a status of 404 (Not Found)
Trying to fetch requirejs from the URL
/lib/requirejs/require.js
Update:
Thanks for the suggestion James, yes I am able to recreate this locally in activator clean start.
I'm pretty sure some configuration in my sbt-rjs is messed up but I don't know what.
This is what my folder structure looks like
public
/ui
/js
/myApp
/controllers.js
/services.js
/main.js
/paritals
/myApp
/partial1.html
I see this error both during activator start and sbt stage.
[info] Error: Error: /home/sajit/angular-play-seed/target/web/rjs/appdir/./main.js does not exist.
The scala.html page which launches the angular app, myApp has this
<script data-main="#routes.Assets.versioned("ui/js/myApp/main.js")" src="#routes.Assets.versioned("lib/requirejs/require.js")"></script>
What am I doing wrong?
Based on the sbt-rjs docs it looks like you need to set the appDir in your build.sbt, like:
appDir := "ui/js/myApp"

Publishing site created with Laravel error

Hi there i follow this tutorial how to setup on the FreeWebHostingArea com :
If your domain is pointed to public_html directory then all content should placed in that directory. How ? let me tell you
Copy all files and folders ( including public folder ) in public html
Copy all content of public folder and paste it in document root ( i.e.
public_html ) Remove the public folder Open your bootstrap/paths.php
and then changed 'public' => DIR.'/../public', into 'public' =>
DIR.'/..',
and finally in index.php,
Change
require DIR.'/../bootstrap/autoload.php';
$app = require_once DIR.'/../bootstrap/start.php'; into
require DIR.'/bootstrap/autoload.php';
$app = require_once DIR.'/bootstrap/start.php';
but when i load the index i get this error
Fatal error: require(): Failed opening required
'/home/vhosts/epernikhardware.eu5.org/vendor/composer/autoload_files.php'
(include_path='/home/vhosts/epernikhardware.eu5.org/vendor/phpseclib/phpseclib/phpseclib:.:/usr/share/pear:/usr/share/php')
in
/home/vhosts/epernikhardware.eu5.org/vendor/composer/autoload_real.php
on line 47
And can amy one explain me how to easily get this simple site to work is it so hard to publish a few web pages with laravel framework. Please help
I don't know about that hosting but for other hosting service such as JustHost, GoDaddy, BlueHost, HostGator... I deploy the Laravel web pretty much easy.
1) Access to the host via SSH, get the source code
$ cd www/
$ git clone https://github.com/ME/MY-PROJECT.git .
2) Get Composer:
$ curl -sS https://getcomposer.org/installer | php -- --filename=composer
3) Update all dependencies (/vendor)
$ composer update
4) Move the /public/.htaccess to the root
$ mv public/.htaccess .
That's all, site is ready. Perhaps, there are more steps in configuring the database but it is not necessary to mention here.
If you host your site on Forge or DigitalOcean, the process would be much easy, just add the source origin, and most of things will be done automatically.
Make sure the PHP version in your computer and the PHP version in the cpanel of your hosting site is the same. I also had the same problem and this helped me.

How can I install sendgrid app in Heroku using git (PHP)?

At the top of my index.php file I have:
require('sendgrid-php/SendGrid_loader.php');
And at the bottom I use this code to send the email:
<?php
if(isset($_POST['submit']))
{
$sendgrid = new SendGrid('app11445063#heroku.com', 'password');
$mail = new SendGrid\Mail();
$mail->
addTo('email#gmail.com')->
setFrom('app11445063#heroku.com')->
setSubject('Subject goes here')->
setText('Hello World!')->
setHtml('<strong>Hello World!</strong>');
$sendgrid->
smtp->
send($mail);
}
?>
I can't get the code to send an email out. I have the proper account from SendGrid and Heroku. The required files are in my directory. Do I have the wrong path to the required file?
The issue was that the SendGrid library was not in the repository in Heroku. Just do a "git status" and add the directory to the commit and then push the directory to Heroku. Make sure you also have the correct path in the "include" in your PHP code.
I believe this has to do with Sendgrid's PHP lib. If you are using SMTP (you must if using heroku) you must also have swiftmailer installed. Otherwise the line 25 won't work in sendgrid-php/SendGrid/Smtp.php
public function __construct($username, $password){
/* check for SwiftMailer,
* if it doesn't exist, try loading
* it from Pear
*/
if (!class_exists('Swift')) {
require_once 'swift_required.php';
}

Resources