minify heroku slugs on build terser - node.js

I recently used "heroku run" and looked around inside my package.json nodejs app, the slug is NOT minified in /node_modules . I am using the standard "heroku/nodejs" buildpack. Looking around, has nobody ever minified their node apps? While I could write a postbuild shell script to run terser on the whole package tree, why isn't this done automatically by heroku and google says nobody does it?

Related

How to deploy node that uses Rollup to heroku

I'm using Rollup.
Also I don't commit npm_modules folder and public folder, where all generated files are. And I can't figure out how to build my app (I have webpack build command) after deploy and setup my server (it's already looking for public folder).
It seems me a bad idea to commit before upload. Maybe there are some gentle decisions... Any thoughts?
Forked from: How to deploy node that uses Webpack to heroku
I don't use Heroku, but according to the answers on the question this is forked from, it should be as simple as this:
"heroku-postbuild": "rollup -c"

Have the server build VS. check in & push a locally built app

What are some pro/cons to pushing built code vs. having the server build it?
This is a general question, but here's my specific scenario to illustrate what I'm talking about:
On Heroku I've got a React app that has a simple express server to do OAuth. Currently, I have a postinstall hook in my package.json that runs a webpack production config to do some extract-text stuff and create a dist/ directory with my bundled, uglifyied code. To get all of this to run on Heroku I had to mark pretty much all of my dependencies as 'dependencies' instead of 'devDependencies'.
I know it's a bad practice to check my dist/ into git but it would save me from having to install a dozen plus node_modules on the server. Any thoughts?

How do I push my build directory to Heroku?

I have a Node project with some front end that results in a ./build directory. How do I setup Heroku to understand that build is what it needs to operate and not my whole project?
Heroku gets all informations of the node.js app using the package.json that needs to be on the main path.Just configure your paths correctly in package.json and it should work fine.

Using Grunt on Heroku without defiling devDependencies

I understand, in general, the most frequent way Grunt is used on Heroku -- load the buildpack, specify your grunt heroku task(s), and include any Grunt plugins you want to use on the Heroku dyno in your package.json:dependencies.
However, I find this to be a rather poor solution, because it miscommunicates about my app. My Grunt plugins are all more like devDependencies, as I will only run anything with Grunt one time (per deploy). My app doesn't directly depend on them to run, as it's mostly minification and template compilation.
I'm also trying to keep compiled files (e.g. .css and .html files when I'm writing in Sass and Handlebars) out of source control, so pushing them over from Github is possible but definitely not what I want.
Is there a way to do all of the following?
exclude .css and .html files from Git
write stylesheets and markup using Sass and Handlebars
push a basic Express app containing these files to Heroku
have Heroku run a server-relative version of my grunt build task (naming it whatever is necessary is fine) to compile and prepare all of the views and assets before launching the web: process
have Heroku's Grunt task intelligently understand that I just want some pre-launch compilation so it will look at devDependencies and install the relevant ones in a perhaps-temporary kind of way
launch the Express server via the web: process
I'm fine with having to write my own buildpack, or whatever needs to be done to do this (what I perceive to be) the right way.
I created the buildpack heroku-buildpack-webapp-client that supports grunt, compass/sass and installs your devDependencies. Maybe you can use this one or have a look at the bin/compile script to see how it works.

Heroku detects Clojure app as Node.js one

Heroku detects app type by presence of files like package.json or project.clj.
I am trying to build Clojure app, so I have project.clj in my root directory. But I also use some node.js tools, so I have package.json too.
Is there a way to tell Heroku what kind of app I build, but keep package.json?
Create a .slugignore file with the contents package.json and Heroku will not see that file, even though it will be in your git archive.

Resources