<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Domantas on Medium]]></title>
        <description><![CDATA[Stories by Domantas on Medium]]></description>
        <link>https://medium.com/@domantas.pelaitis?source=rss-2316be22ae58------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*pjodcSmx937wUqpsmg_3iQ.jpeg</url>
            <title>Stories by Domantas on Medium</title>
            <link>https://medium.com/@domantas.pelaitis?source=rss-2316be22ae58------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 20:11:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@domantas.pelaitis/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to use local builds on Heroku]]></title>
            <link>https://medium.com/hackernoon/how-to-use-local-builds-on-heroku-5d89ca3fc1e9?source=rss-2316be22ae58------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d89ca3fc1e9</guid>
            <category><![CDATA[sap]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[npm]]></category>
            <category><![CDATA[heroku]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Domantas]]></dc:creator>
            <pubDate>Thu, 27 Jun 2019 05:54:36 GMT</pubDate>
            <atom:updated>2019-07-10T06:48:24.316Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JYGU_MEBZaJfWw4HnQtvcg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@randyfath?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Randy Fath</a> on <a href="https://unsplash.com/search/photos/build?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>I’ve seen a few tutorials, how to deploy single page web applications on Heroku, but I’ve really struggled to do it myself, because I wanted to do it a bit differently. I found a way how to deploy any SPA to Heroku using local builds.</p><h4>Why</h4><p>Well, the problem we faced was that our app had some npm packages (node-sass to be specific) that Heroku failed to use for some reason. So this deployment flow might help you if you can build your application locally without any problems, but the build process fails on Heroku.</p><h4>How</h4><p>First of all, we will need an express app that will serve our web app. It should look something like this:</p><pre><em>const </em>express = require(‘express’)<br><em>const </em>path = require(‘path’)<br><em>const </em>port = process.env.PORT || 8080<br><em>const </em>app = express()</pre><pre><em>// the __dirname is the current directory from where the script is running<br></em>app.use(express.static(path.join(__dirname, ‘/build’)))</pre><pre>app.get(‘*’, (req,res) =&gt; {<br>  res.sendFile(path.join(__dirname + ‘/build/index.html’))<br>})</pre><pre>app.listen(port, () =&gt; console.log(‘App listening on port ‘ + port))</pre><p>By default, Heroku installs development dependencies. And if we are trying to deploy an app that is already built we can skip the installation of development dependencies. This can be done by using the following command:</p><pre><strong>heroku config:set NPM_CONFIG_PRODUCTION=true YARN_PRODUCTION=true</strong></pre><p>Now if your app uses some of the dependancies that are development dependencies the build on Heroku might still fail. What we want to do is skip building process completely. And this can be done by adding the following npm script to your <strong>package.json</strong></p><pre>“heroku-postbuild”: “echo Skip build on Heroku”</pre><p>Now heroku will use this script instead of the default build script. And this script allows to skip the build process completly.</p><p>Finally, we add a <strong>Procfile </strong>with text:</p><pre> “web: node app $PORT”</pre><p>Notice, name this file “Procfile” and don’t use any file extensions. This is Heroku specific file.</p><p>Finally, to use this deployment flow all you have to do is build your app locally and push it to Heroku.</p><p>I would not recommend this approach in production, but if you are just hacking something and can’t figure out why your builds fail this might do the job.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d89ca3fc1e9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/how-to-use-local-builds-on-heroku-5d89ca3fc1e9">How to use local builds on Heroku</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>