-
Notifications
You must be signed in to change notification settings - Fork 304
consider bringing back CLI build plugins #524
Comments
i'm not sure how to do this. the field each plugin acts on is important, and the way it is ordered with the default plugins matter as well. i think if you wanted to do this right now, you would have to re-use all the default middleware manually and specify the fields: component build
--use-scripts es6modules
--use-scripts js
--use-json json
--use-templates templates etc. plus, there are also custom options and such you would have to handle. there's just too many different dimensions, and it would end up being larger than just writing a JS file. i'm trying to think of a way where you can just just create a js file that looks like: exports.scripts = function (build) {
build
.use()
.use()
.use()
} without returning anything, and set its path as an env variable or something. |
As far as I understand, you have to define the default middleware manually as well in a build script, right? Thats one of the reason why it is so highly redundant and copy-pasty. Its also that I might want to have two different builds, one with component-jade, one with component-jade + component-istanbul. I just think make/shell is more convenient. |
the use-case isn't the problem. it's actually implementing it. you're trying to map a 1-2 dimensional option space to like a 5 dimensional option space, which is pretty difficult. |
+1 for bringing CLI plugins back The way browserify was able to achieve this is really super convenient. Does it make sense to just have specified --use-X middleware applied after the default stuff? |
I also thought the CLI option was convenient. But I was thinking, wouldn't it be more convenient to list the build plugins in component.json? That way you wouldn't have to bother with a shell script (or type them out each time), and they could even be downloaded / resolved the way dependencies are. As for ordering and configuration options, what about the following:
|
setting them up in the manifest might be reasonable, still very leaky compared to scripting but less leaky than via the CLI at least |
Leaky as in leaky abstraction? I suppose the non-deterministic ordering makes it that way. But having plugins be components which can, themselves, depend on / delegate to other plugin components provides a DRY way of composing deterministic builder pipelines. Then, being able to specify at least a root plugin (pipeline) in the manifest could give people the brevity they want. (Said root plugin could be remote or local, allowing people to reuse existing published pipelines, or switch to customized local ones with zero friction.) Having a single combined pipeline (selected over by regex), instead of separate pipelines for each asset type, also simplifies things, IMHO. |
yeah just leaky as far as logic you can apply and how and what options you pass etc. for simple cases cli/json are nice |
I'm currently assessing the feasability of using Component (for me and my team) as the ONLY tool for structuring, reusing and compiling CSS across different projects (using SuitCSS, at least with Rework & minification) Use case : Build SuitCSS Components & custom ones with Rework + minification Having no scripting for simple cases is less error-prone, less time-consuming - and of course, lowering the perceived difficulty of this tool is a critical factor of its immediate adoption. "list the build plugins in component.json" |
@Paulmicha We're currently using Component for all of our CSS, and have been for a while, with a Makefile to run Myth over the built file and using Suit for some utils. Works a treat and highly recommended. Just use a makefile and everything is nice and simple. |
"with a Makefile to run Myth" -> this is an extra tool, and the people I will try to convince will probably just hear "it works if you also use this like this and..." and then give up. |
Well I mean you'll probably have some sort of build tool, and in that you'll probably be running a minifier over it, so just run Myth/Rework over it too :) |
"you'll probably have some sort of build tool" -> No : that's the whole point, I think. |
I basically agree that @visionmedia As far as the passing of options goes that does not seem like that hard of a problem to solve. Either improve the CLI parser with |
I've been giving some thought to how make this feature less magical / easier to reason about. What about something like this inside component.json: {
"build": {
"myFile1.js": ["plugin1", "plugin2", "plugin3"],
"myFile2.js": ["plugin2"],
"myFile3.css": ["plugin7", "plugin8"],
// etc
},
"plugins": {
"plugin2": { /* configuration */ },
"plugin7": { /* configuration */ }
// etc
}
} The downside of this is that, with less magic, it's duplicating build script functionality. The upside is that it's friendlier / easier for common cases. |
@jonathanhefner generally I like, seems quite usable, and multiple bundles fall out of this super simply, no? I assume that all plugins would first check |
rather than adding a bunch of weird stuff to |
@stephenmathieson Hm not against the idea at all but another file to specify a few fields is not great for the end user. Too much modularity for the end goal in a lot of use cases I would imagine. |
I kind of see the reasoning to distinguish between simple builds with the CLI and more complex ones that use plugins and need a build scripts.
But its just soooo inconvenient to copy-paste build scripts all over for things that could be done in 2 lines of shell.
Going down that road, one might just use gulp or even the highly redundant boilerplate heavy grunt.
The text was updated successfully, but these errors were encountered: