Jigsaw: How to copy single asset from root with Laravel Mix/Webpack?

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

When compiling assets for Netlify, I not only need all the resources in _assets and assets to be copied, but also _redirect on the root level, which has to go to build_production/_redirects (only when npm run production of course.

I know that I can use mix.copy('_redirects', 'build_production/_redirects'); but I neither know whether that would be the right way to do, nor where to put it in the Laravel Mix/webpack config system.

Most helpful comment

@minthemiddle Another solution is to store your redirects in a netlify.toml config file, as mentioned here.

All 2 comments

If you only want to copy the files when running npm run production, you can do something like this:

if (mix.inProduction()) {
   mix.copy('_redirects', 'build_production/_redirects');
}

@minthemiddle Another solution is to store your redirects in a netlify.toml config file, as mentioned here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

luklus picture luklus  路  11Comments

dgursh picture dgursh  路  4Comments

nathangross picture nathangross  路  3Comments

slavarazum picture slavarazum  路  6Comments

imaje89 picture imaje89  路  3Comments