How to overwrite or remap one directory to another
See original GitHub issueIs it possible to “remap” a directory to another using polka and sirv?
I created a repository to test the following code:
// index.js
const polka = require('polka');
const sirv = require('sirv');
const { PORT=3000 } = process.env;
polka()
// Make "localhost:3000/components" to serve content from "public/compiled_components"
.use('components', sirv('public/compiled_components'))
// And everything else remains the same, on "public"
.use(sirv('public'))
.listen(PORT, err => {
if (err) throw err;
console.log(`Running on localhost:${PORT}`);
});
My project has the following structure:
project
│ index.js
│
└───public
│ │
│ └───components (non compiled components)
│ │ component1.txt
│ │ component2.txt
│ │ ...
│ └───compiled_components (automatic compiled components, during development time)
│ │ component1.txt
│ │ component2.txt
│ │ ...
But, on the path localhost:3000/components
, instead of serving the content of public/compiled_components
it is still serving the content of public/components
Issue Analytics
- State:
- Created 4 years ago
- Comments:15 (4 by maintainers)
Top Results From Across the Web
How to move and overwrite subdirectories (and files) to parent ...
How i usually do this: packing the subdir content into a tarball, moving the tarball up to the parent directory and then extract...
Read more >How do I copy files, overwriting existing files? - Stack Overflow
I have the following code to copy the files from one directory to another directory... const string sourceDir = @"C:\AppProject\Smart\SmartStaff\site\document"; ...
Read more >Make scp always overwrite or create directory - Server Fault
I am using scp to copy a directory from one remote server to a new directory (IE just changing the name) on another...
Read more >How can I copy a (big) directory over another changing only ...
You can use rsync to do this, the command I use is rsync -tr "folder to copy from" "folder to copy to". e.g....
Read more >The DistCp - Update and Overwrite - Cloudera Documentation
The DistCp -update option is used to copy files from a source that does not exist at the target, or that has different...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Great! The last sample will only work in the next version of Polka. The reason it isn’t currently working is because stable polka is running use() before use(‘/foo’)
Thanks a lot!