Copyfiles not running?

With the attached file, the .htaccess file is not copied when running production builds with 3.5.9 Needle engine, this used to work before. I know during updates we needed to remove the copyfiles line from the build commands at the top. Is that connected?

Original Post on Discord

by user 103054507105067008

You dont have to remove the copy files script. You can keep using it and just add your custom files in the copyFiles array

Optionally you can try adding a build : { copy: [ "source.file" : "target.path" ] } object to the needle.config.js

I’ll try that tomorrow

by user 103054507105067008

I might have got confused around the 3.* upgrade where you mentioned that CopyFiles isn’t needed next to vite build or tsc

by user 103054507105067008

It isnt for the default files and assets but of course if you have custom files like the htaccess they still need to be copied somewhere/somehow

It’s my bad when you said copyfiles wasn’t needed anymore in that build command list, I assumed it was moved elsewhere or happened automatically. I’ll make sure to put it back and check it runs good which it should :slightly_smiling_face:

by user 103054507105067008

Hello @ROBYER1 started adding some more documentation about this here: Needle Config | Needle Engine Documentation

In general we added more docs to Typescript Essentials | Needle Engine Documentation
and Scripting Introduction | Needle Engine Documentation recently

let me know if you have any feedback

I’ll give the new ‘copy’ a try by replacing the old copy-files, I assume the format is the same anyway when writing up the array of files for it to copy?

by user 103054507105067008

If all you want to copy is the htaccess then adding

"build": {
    "copy": [

should do it (assuming its in the root dir next to the index.html). It’ll then land in dist/.htaccess

That’s it, then I guess if I want a file in a subfolder to be copied to a specific directory how do I do that? e.g. coolfoldername/.htaccess to the same folder name without copying everything else in that folder?

by user 103054507105067008

That’s not supported right now. But you can still use the copy-from-to npm package for things like that

In that case can I still use the old copy files instead?

by user 103054507105067008

You can use anything as you see fit. The copy-files npm package is good at, well, copying files with some configuration. If you find another one that suits your case better you can use that. Your choice :wink:

Exactly, just add the additional file .htaccess file to the copy-from-to script then, I think it has options for configuring the source and target paths

That’s what I love about the build process you have in place, it is very flexible

by user 103054507105067008