top | item 14643114

(no title)

duval | 8 years ago

Yours do that if you want, but then you might have customers using large parts of the code base that other don't have access to so you want to use code splitting. You probably have some images and want them to look good on all screens but also want them to be a small size so you use image srcset but you need to output 6 images for all the sizes. If you're using svgs you might want to inline these. I mean it goes on and on really, just look at all the headings within the webpack docs if you want more insight. I can understand why it seems crazy and perhaps it is more crazy than I think but if you want you can just concatenate all the scripts, if you want more bells and whistles then you can too

discuss

order

pdkl95|8 years ago

> code splitting

That should only take a few lines in a Makefile.

    JSTARGETS = foo.js bar.js
    
    build-js: $(JSTARGETS)
    foo.js: foo_main.js lib_a.js lib_b.js
            cat $< > $@

    bar.js: bar_main.js lib_a.js lib_x.js lib_y.js
            cat $< > $@
With make's builtin topological sort, adding dependency information to control the order or other unusual build requirements isn't hard to add.

> output 6 images for all the sizes

    IMAGES=( baz quux )
    IMGSRC=(patsubst %,src/images/%.jpg,$(IMAGES))

    IMGSML=(patsubst %,build/images/%-small.jpg,$(IMAGES))
    build/images/%-small.jpg: src/images/%.jpg
            convert $< -resize 25% $@

    build-images: $(IMGSML)

ricardobeat|8 years ago

The main difference is that the JS source is being parsed, and most of the build steps operate on the AST. This is what allows things like transpiling modern language features to more broadly supported versions, doing dependency resolution, pruning, and automatic splitting (imagine your Makefile with 300 js files). Remember that JS does not yet have a built-in module system - simply pasting source files together means you'll be rolling your own.

RonanTheGrey|8 years ago

In fact this is exactly what early JS build systems looked like. When I worked at Bing this was exactly what the production deployment script looked like (at a simple level).

It no longer does. The tools move on because the uses get more complex. See the sibling reply here for a good reason why.