It makes sense I think to keep using tools from within the Symfony ecosystem as much as possible, as people would likely be more familiar with Encore than Laravel Mix.

Comments

opdavies created an issue. See original summary.

opdavies’s picture

Version: 8.x-2.x-dev » 8.x-3.x-dev

I'm still unsure if I want to make this change.

I like the plugin ecosystem for Mix (e.g. PurgeCSS) and it has some functionality like Browsersync that Encore currently doesn't have.

Alternatively, do we go more lightweight and use custom npm scripts with postcss, though in most, if not all, cases something like Mix or Encore needs to be used for JS compilation.

opdavies’s picture

Version: 8.x-3.x-dev » 4.x-dev
lhockley’s picture

I know I am a bit late to the party here, but I would like to +1 the "lightweight" option.

Here is a minimal Tailwind template I created a while back, which simply uses postcss: https://github.com/xdega/tailwind-postcss

Tailwind is CSS toolkit, therefore I think it is out of scope to let it dictate a JS tooling strategy.

Thoughts?

opdavies’s picture

As you can tell, I'm still undecided on what I want to do with this issue.

I usually use Webpack Encore but I still have some Laravel Mix based themes. I think that most of the time, we need to add some JavaScript into our themes which is why I usually reach for one of those and haven't really thought about using PostCSS or the tailwind build command, though that might make it easier for people who want to use Encore, Mix, Gulp or something else completely different if they want to.

I'll give it some more thought and see what would go into 4.x.

lhockley’s picture

It is probably worth mentioning that, for small amounts of JS, I have found Webpack to be a lightweight option with often minimal amounts of configuration required.

opdavies’s picture

It's been a while since I tried setting up Webpack from scratch, though I know that it can be quite complicated which is why tools like Laravel Mix and Webpack Encore (which are wrappers around Webpack) exist and are used.

lhockley’s picture

So. Webpack has actually come a long way.
Version 4+ requires no configuration, with a reasonable default:
https://webpack.js.org/guides/getting-started/

I have projects where I have combined JS and CSS in Webpack, using the PostCSS plugin. But I have ran into issues with Purge not working well. Here is one such project:
https://github.com/xdega/webfresh-v2/blob/master/webpack.config.js

I am thinking you could use two build scripts: Webpack for JS (if needed), and PostCSS for CSS.
The benefit here, would be that if a user doesn't need any custom JS in their theme (maybe using a an external library or something), then they don't even need to run the build script for JS for working with this theme.

opdavies’s picture

Attached are some patches that would remove Laravel Mix and move to use npm scripts.

One contains the tooling changes without re-compiling the CSS, just to make it clearer what the changes are.

This makes it more consistent with most of the installation instructions on the Tailwind website and leaves the decision to the user if and they need to compile JavaScipt.

opdavies’s picture

Title: Replace Laravel Mix with Webpack Encore » Replace Laravel Mix with npm scripts

  • opdavies committed 2e854e1 on 4.x
    Issue #3085759 by opdavies: Replace Laravel Mix with npm scripts
    
opdavies’s picture

Status: Active » Fixed

Laravel Mix removed, replaced with npm scripts in 4.x.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.