Closed clintwood closed 9 years ago
You can get part of the way there with this:
lib = gobble('src').transform('babel');
module.exports = gobble([
lib.moveTo('lib'),
lib.transform('esperanto', {...}).moveTo('dist')
]);
There isn't a way to write to multiple top-level directories (I tried gobble watch --force .
just now and it nuked my project folder - oops!) so I guess the next best thing is symlinks?
ln -s .tmp/dist dist
ln -s .tmp/lib lib
gobble watch .tmp
With build
rather than watch
it's more straightforward obviously, you just need to copy the directories after building.
Ahhh... no... sorry about the nuke!
I will fiddle with that, thanks. Ideally I'd like to do an intermediate build (to ./lib for easy debugging, etc.) then bundle into ./dist...
I'll close for now and re-open if I don't win! Thanks!
You could use environment variables - off the top of my head, though I can't try this out right now:
gobble watch lib # environment defaults to 'development' - override with --env whatever
gobble build dist # defaults to 'production'
var prod = gobble.env() === 'production';
module.exports = gobble( 'src' )
.transform( 'babel' )
.transformIf( prod, 'esperanto-bundle', {...});
The example I gave in the OP was a contrived example, what I'm really doing is taking the same source, ./src
and building for different targets, potentially for iojs
where I would not need that much 'babelifying' versus say for browser where most of the es6 would need to transformed to es5 and with different bundling configurations. So in a nutshell I'm looking for more access or control of the processing pipeline at the different transform stages... So potentially I would like to do a simple babel transform to iojs
'compatible' es6 then take that as the source and further transform or bundle for other targets (e.g. other node.js versions or browser targets). I have what I need for now but would be interested if you can see a way of doing this...
I sometimes find myself doing this sort of thing:
var nodes = [
gobble( 'foo' ).transform( 'foo' )
];
if ( gobble.env() === 'bar' ) {
nodes.push( gobble( 'bar' ).transform( 'bar' ) );
}
module.exports = gobble( nodes );
Between that and transformIf
you can basically do whatever you need. Though if you find yourself coming up against the hard edges repeatedly and it seems like something Gobble should cater for, then I'm keen to hear about it.
@Rich-Harris, sorry for not coming back to you earlier! I'm under time pressure for several projects so will revisit this when I get a gap! Thanks.
@clintwood not at all, I know exactly what it's like!
Given a single
./src
directory is it possible to create agobblefile.js
that could 'build' more than a single output?In this contrived example given
gobblefile.js
:Doing
$ gobble watch ./dist
builds all transforms code to./dist
(which is expected).How would I get the
babel
transform step to be output to say./lib
in the above case?