Jigsaw: Ability to pass through underscore files

Created on 2 Jan 2019  路  3Comments  路  Source: tighten/jigsaw

Netlify has a feature where you can put a _redirects file at the root of your site. Obviously jigsaw ignores this file when building. It would be great if there was a way to pass this through to the build.

I've had a dig through the docs and GitHub issues but found no obvious way to do this. If we could escape a file in some way to highlight it should be passed through, double underscore for example? Or an array in the config file maybe? Or both?

I realise this may be possible using the Node build process which is what I'm about to look into but not all projects may be using Node.

Thanks, keep up the great work!

Most helpful comment

Or, if you want to keep a pure PHP build pipeline, you can put this in bootstrap.php

$events->afterBuild(function ($jigsaw) {
    copy('source/_redirects', "build_{$jigsaw->getEnvironment()}/_redirects");
});

All 3 comments

Might just be easier to use a netify.toml file instead, since you can also define redirects there.

Otherwise, I'd just create the _redirects file without a _ prefix so that Jigsaw copies it over, and then simply rename it after the site is built, in tasks/build.js:

command.get(bin.path() + ' build -q ' + env, (error, stdout, stderr) => {
  console.log(error ? stderr : stdout);

  // rename `build_${env}/redirects` file to `build_${env}/_redirects`

  if (browserSyncInstance) {
    browserSyncInstance.reload();
  }
});

I think both of these are good solutions for redirects at the moment, thanks @hellocosmin!

Or, if you want to keep a pure PHP build pipeline, you can put this in bootstrap.php

$events->afterBuild(function ($jigsaw) {
    copy('source/_redirects', "build_{$jigsaw->getEnvironment()}/_redirects");
});
Was this page helpful?
0 / 5 - 0 ratings

Related issues

mrgodhani picture mrgodhani  路  8Comments

lxqueen picture lxqueen  路  7Comments

Log1x picture Log1x  路  8Comments

DRogueRonin picture DRogueRonin  路  8Comments

imaje89 picture imaje89  路  3Comments