3 ms·
I use makefile to build my javascript and css. It works brilliantly. I initially used Gulp, but started running into problems when there were build errors that
by bigmanwalter 9y ago
I use makefile to build my javascript and css. It works brilliantly. I initially used Gulp, but started running into problems when there were build errors that would crash Gulp so I had to use a plugin called Gulp-plumber just to keep the watcher going. Then when I started having a somewhat more complex chain of dependencies I didn't enjoy having to manually specify the build order. The final nail in the coffin for Gulp is when I wanted to dynamically alter flags based on certain conditions, whether it was a debug or prod build for example, it just started getting messier and messier.
I am completely satisfied with Make as a replacement. Took me a couple days of hacking to figure out how to set it up and it's been problem-free ever since.
By far, my favourite aspect is that I no longer need to depend on flimsy gulp-specific wrappers. I just call my build tools natively.
- andreareina 9y agoI used Make for my javascript for a while, but having to update the makefile everytime dependencies changed got annoying. Now I just `webpack --watch`; the startup time isn't great, but it's a one-time cost and the recompile happens faster than I can switch to the browser.
- bigmanwalter 9y agoI write my makefile once at the beginning of a project and never touch it again. If you need to update yours with every new dependency, you might have your makefile set up sub-optimally. I make sure to have something like the following to include all my js/css dependencies. JS = $(shell find . -name "*.js" -o -name "*.json") CSS = $(shell find . -name "*.scss" -o -name "*.css") I use a small program called watch https://github.com/tj/watch https://github.com/tj/watch written by TJ Holowaychuck (the inventor of the Express framework) which automatically re-runs my makefile every second. As make is smart enough look for modified files and rebuild only what is necessary, it works quite well.
- andreareina 9y agoI'm writing for the browser so imports have to be bundled into the final product; I'm not seeing how that will rebuild a.js (depends on b.js) when b.js changes.
- bigmanwalter 9y agoYou could do something as follows assuming all source files are in src/, your entry point is src/a.js and your output is build/scripts.js. I use browserify for my compilation but this would work similarly with webpack. JS_FILES = $(shell find ./src -name "*.js") JS_ENTRY = ./src/a.js JS_OUT = ./build/scripts.js $(JS_OUT): $(JS_FILES) browserify $(JS_ENTRY) > $(JS_OUT) Now anytime any js files within the src/ directory are modified, make will rebuild scripts.js
- molszanski 9y agoI also use Makefile for all my node/docker/frontend needs. It is an EXCELLENT entry point for all of the project scripts, needs etc. Check it out: https://gist.github.com/molszanski/56de03b54f66885ef415af84e06cda7f https://gist.github.com/molszanski/56de03b54f66885ef415af84e... npm scrips are also awesome. But editing and maintaining them inside a package.json is not cool