3 ms·
I 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 make
by bigmanwalter 9y ago
I 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