mhanberg / jekyll-postcss

A plugin to use PostCSS plugins like Autoprefixer or Tailwind CSS with Jekyll.
MIT License
66 stars 12 forks source link

Netlify issue: missing node_modules packages. (resolved, but FYI) #38

Open jayroh opened 2 years ago

jayroh commented 2 years ago

In your README you mention that you must install postcss with npm or yarn. I'd done this with yarn add <package-name> -D, which places things in the devDependencies hash key in package.json. This is fine. Typically running bundle exec jekyll build locally will result in everything working just fine. Great!

Here's the hiccup: In many jekyll + postcss blog posts (eg: here) there are instructions that instruct people to set the following ENV variables:

When building for production, always set JEKYLL_ENV=production and NODE_ENV=production on the command line. When these variables are set to production, unused Tailwind styles are purged and the output is processed with cssnano.

This where the problem comes in. When deploying and building on Netlify NODE_ENV=production + yarn add ______ -D seems to result in an empty ./node_modules directory.

When I moved everything from devDependencies to dependencies in packages.json then everything started working.

I don't know if this is a Netlify thing or not but, in the off-chance anyone shows up here with missing node_modules packages, this might be the answer.

TLDR: Do not install your node dependencies via yarn add .... -D or npm install <package-name> --save-dev