caffeinated / themes

:art: Laravel Themes package with support for the Caffeinated Modules package.

Home Page:https://caffeinatedpackages.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compile Assets

larry-tx opened this issue · comments

I'm very confused, and it's probably due to my lack of knowledge of Laravel and Laravel Mix. I've installed the plugin and created a theme. Caffeinated/themes put my theme at ProjectRoot/themes/MyTheme and created a webpack.mix.js. I then ran npm run dev. That did nothing with the webpack file located with my theme. When I switch to the theme directory and attempt to run npm run dev again, it attempts to run the root directory script. Am I to assume that the ProjectRoot/themes/MyTheme/webpac.mix.js is some kind of leftover from development that should have been deleted?

With developing a theme, I will, of course, have scss files to be compiled. Of course, I will have additional JavaScript files to be added. How do I get all this done? Do I simply disregard the webpack misadventure, and use the ever-reliable, non-problematic gulp?

I must confess that I've spent over six hours working on what should be a very simple task. It's true that I'm new to Laravel (and just about decided to flee, running as fast as I can back to frameworks that actually have quality control and adequate documentation). I've looked at the documentation multiple times and had colleagues look at it too. None of us can find any explanation for how to get this to work. Do I go back to Yii2 and Symfony, or is there some way to get this thing to work?

commented

The root of Laravel and your theme would be two separate entities. Your theme should have its own package.json and laravel mix config (or whatever other build system you wish to use). When you switch to your theme, you will need to run npm install and then npm run dev. I'm not sure why it would run the root Laravel package.json - I'm guessing npm may traverse back until it finds what it needs.

Webpack is inherently more complex than something like gulp, though Laravel Mix does take care of the complexity there. Out of the box we simply provide the same package.json and laravel mix file bundled with Laravel within your theme. You can totally scrap that and use whatever you're comfortable with 👍

tl;dr

  1. php artisan make:theme YourTheme
  2. cd to your theme
  3. npm install
  4. npm run dev

Hope this clears things up. Don't hesitate to reach out if you're still running into issues!