Havardpede
Hey I am currently lost. I have finally managed to deploy my phoenix project to Heroku. However, it does not manage to digest the assets. or more specifically, the stylesheets.
when calling mix phx.digest locally, it produces the assets as expected. however, this does not seem to be the case when I use heroku. I have the following build packs.
1. https://github.com/HashNuke/heroku-buildpack-elixir
2. https://github.com/gjaldon/heroku-buildpack-phoenix-static.git
in assets/js/app.js:
import css from "../css/app.css";
config/prod.exs:
cache_static_manifest: "priv/static/cache_manifest.json"
phoenix_static_buildpack.config:
clean_cache=false
# We can change the filename for the compile script with this option
compile="compile"
# We can set the version of Node to use for the app here
node_version=13.8.0
# We can set the version of NPM to use for the app here
npm_version=6.13
# We can set the version of Yarn to use for the app here
yarn_version=1.22.0
# We can set the path to phoenix app. E.g. apps/phoenix_app when in umbrella.
phoenix_relative_path=.
# Remove node and node_modules directory to keep slug size down if it is not needed.
remove_node=false
# We can change path that npm dependencies are in relation to phoenix app. E.g. assets for phoenix 1.3 support.
assets_path=assets
# We can change phoenix mix namespace tasks. E.g. `phoenix` for phoenix < 1.3 support.
phoenix_ex=phx
my webpack:
const path = require("path");
const glob = require("glob");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const PurgecssPlugin = require("purgecss-webpack-plugin");
const globAll = require("glob-all");
// Custom PurgeCSS extractor for Tailwind that allows special characters in
// class names.
//
// https://github.com/FullHuman/purgecss#extractor
class TailwindExtractor {
static extract(content) {
return content.match(/[A-Za-z0-9-_:\/]/g) || [];
}
}
module.exports = (env, options) => ({
optimization: {
minimizer: [
new OptimizeCSSAssetsPlugin({}),
new PurgecssPlugin({
paths: globAll.sync([
"../lib/myapp_web/templates/**/*.html.eex",
"../lib/myapp_web/views/**/*.ex",
"../assets/js/**/*.ts",
"../assets/js/**/*.js"
]),
extractors: [
{
extractor: TailwindExtractor,
extensions: ["leex", "eex", "ex", "html", "js"]
}
]
})
]
},
entry: {
"./js/app.js": glob.sync("./vendor/**/*.js").concat(["./js/app.js"])
},
output: {
filename: "app.js",
path: path.resolve(__dirname, "../priv/static/js")
},
module: {
rules: [
{
test: /\.ts?$/,
exclude: /node_modules/,
use: {
loader: "ts-loader"
}
},
{
test: /\.js?$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
},
{
test: /\.css$/,
// Use the postcss-loader
use: [MiniCssExtractPlugin.loader, "css-loader", "postcss-loader"]
}
]
},
resolve: {
extensions: [".tsx", ".ts", ".js"]
},
plugins: [
new MiniCssExtractPlugin({
// create a generatated css file
filename: '../css/app.css'
}),
new CopyWebpackPlugin([{ from: 'static/', to: '../' }])
]
});
I am currently using TailwindCSS, and also tried to use TS instead of JS, but mostly undid it, as I thought it might have been the culprit.
Trending in Questions
Hi all,
I’m working on a Phoenix project where I need to make external HTTP requests and I’m trying to choose between Req and HTTPoison....
New
I’m very new to Elixir, so sorry if this is a silly question:
I am wondering what happens to the mailbox of a process when the machine i...
New
How do I tell Hologram not to escape HTML when substituting into templates?
{Textile.render(@product.long_description)}
escapes the HTM...
New
Background
When trying to execute mix release on a Windows 11 machine for a Phoenix project I get the following error:
* assembling mark...
New
I’d like to create a file with 600 permissions (rw-------), but there’s a race condition if I create it and then change the permissions. ...
New
Is there a way to import record definitions in the iex shell for pretty printing (similar to the rr command in the erl shell)? This woul...
New
When I use Mix.install with a git dependency, using git@github.com:... how do I change the SSH identity used?
I’ve got two Github accoun...
New
Other Trending Topics
Hey there,
I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first.
...
New
Hi everyone :waving_hand:
I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
New
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #code-sync
- #discussion
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #elixirconf-us
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #elixirconf-eu
- #processes
- #security
- #api
- #forms
- #performance










Showing Posts 1 to 7- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
outlog
what is in your
compilefile? see GitHub - gjaldon/heroku-buildpack-phoenix-static: A Heroku buildpack for building Phoenix's static assets · GitHubHavardpede
I am currently using the default compile file:
Havardpede
I tried
mix phx.digestlocally again, and managed to recreate the issue.the file
app-0231d5a0f0da253dc7450232215221d5.csswas created inpriv/static/csswith the following content.
This part is from
app.css, which makes it seem like only the tailwind assets css is missing.update: The app.css file in priv/static/css was created correctly when i started the application.
Havardpede
I have now removed
/priv/static/from.gitignoreand it worked.outlog
you really don’t want to do that - you’ll get burned down the line.. do you have parity between dev/prod eg same node version etc..
also what is in you package.json scripts? is the deploy script correct?
Havardpede
Yeah that was my thought too.
All the tools required for the buildpacks are set to the exact same version as in my dev environment.
these are the scripts in package.json
Really appreciate your help, @outlog
Havardpede
I realized I had both tailwindcss and the postcss dependencies within
devdependenciesrather thandependencies. I dont know if this would make a difference during the build process or not. This is how thepackage.jsonis structured: