Just wondering if you guys split your development/production environments in anyway? For example I’m using grunt to concatenate css and js, as well as run a few other tasks for my build of the site, however it seems running this task last minute then changing the script reference in my footer from something like:
Isn’t the smartest way of doing things? I guess I could use only the built script in my footer during development, and then run a PHP sever with grunt, but this feels a bit…wrong? (especially for debugging etc.)
For what it’s worth (and for anyone else’s future reference), I just use laravel-elixir for all front-end stuff. There’s not much fiddling you’ll have to do to get it working. There are a few things that I couldn’t get working (like BrowserSync), but not a big deal.
I link to the same files in dev as production. But when building for production, I just run gulp --production and the lib will minify, compress, etc. Then I push those up to the server.
This way I don’t have to mess with <link> hrefs or edit any configs for the sake of FE asset paths.
There are several such solutions such as Gulp and Grunt.
If you don’t like configuring and running the code from the terminal, there are also GUI tools like CodeKit and Prepros.
I use grunt, but I looking for solution, which do this for and I also cen debug page within same code, if you understand what I mean Now I must build everytime, when I make some change…
Task runners support so-called “watch tasks” that will run your build process every time you change a CSS or JS file. grunt-contrib-watch is the one for Grunt.
If I use build everytime when I chenge something it’s time consuming.
I looking for something like this Wordpress plugin: https://wordpress.org/plugins/bwp-minify/ which do this when page is loaded and save this final file to cache…
I use Gulp for my projects, but it should be similar for Grunt: If you use watch, rebuilding should take way less than a second (or even less than 200 ms) after saving in your editor. Watch works automatically, so you don’t need to manually run a task.
Building CSS in a CMS plugin isn’t useful at all as it doesn’t change on the final public site. You build it once, upload it and you are done. Those plugins actually perform worse than building before uploading.