Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an option to use custom folder name instead of _next #9460

Closed
andrey-semin opened this issue Nov 19, 2019 · 16 comments
Closed

Provide an option to use custom folder name instead of _next #9460

andrey-semin opened this issue Nov 19, 2019 · 16 comments

Comments

@andrey-semin
Copy link

Feature request

Is your feature request related to a problem? Please describe.

We tried to run next export command to generate static assets and to pack our app with cordova or capacitor. It turns out that those engines omit any folders that begin with an underscore without warning. And once you run next export some of the files are put inside of _next directory. So, to run the app one has to find a way to rename this folder and all links inside generated files not to include underscore.

Describe the solution you'd like

It would be really nice to have an option available in next.config.js to provide a name of that directory to be used instead of _next.

@timneutkens
Copy link
Member

We're not planning to allow changing the _next folder name as of currently.

@andrey-semin
Copy link
Author

andrey-semin commented Nov 20, 2019

@timneutkens any advices on how we can wrap the app then?

@NimitMak
Copy link

NimitMak commented Feb 27, 2020

@andrey-semin I handled this issue via Nginx Routing.

What i assumed while making this Nginx Routing is that every file will have unique hash and file name combination.

This is the snippet of code of Nginx Routing which i used.

location /static/ {
    try_files $uri @server1;
}
location @server1{
    proxy_pass http://192.168.1.1$uri;
    proxy_intercept_errors on;
    recursive_error_pages on;
    error_page 404 = @server2;
}

location @server2{
    proxy_pass http://192.168.1.2$uri;
    proxy_intercept_errors on;
    recursive_error_pages on;
    error_page 404 = @server3;
}

location @server3{
    proxy_pass http://192.168.1.3$uri;
}

What the above code does is, whenever Nginx encounters /_next/ it will first try that URL with @server1, if that Server responds with 404, the Nginx then transfers the request to @server2 as mentioned in error_page param.

This example works like:
try_files $uri @server1 @server2 @server3

This worked for me as i had 2 apps which were developed on Next and both has _next route.

Let me know if this solves your problem.

@kud
Copy link

kud commented May 9, 2020

Hello,

I'm trying to figure out why but for the moment, deploying on gh-pages doesn't work well.

I succeeded to deploy my website, everything is quite ok but the folder _next doesn't exist for the http server. It's here in the gh-pages branch in git, but no files available from the http server.

As they use by default jekyll, I'm pretty sure that any files named with _ as prefix are ignored.

So yeah, it could be great to be able to change this name.

@kud
Copy link

kud commented May 9, 2020

I think I found the solution: https://github.blog/2009-12-29-bypassing-jekyll-on-github-pages/

@khcd
Copy link

khcd commented Nov 2, 2020

I'm facing this issue currently as using nginx to micro frontends

@NimitMak what is your logic behind using three servers for this?

@NimitMak
Copy link

NimitMak commented Nov 2, 2020

@kang-chen This was before we had basepath support from Nextjs, so we had 3 different apps running on next.js and each had _next folder, that's why we needed to add 3 different servers in the Nginx config which will check for respective files in each _next path, so that we don't encounter 404. Let me know if you need more details.

@andrey-semin
Copy link
Author

Any updates on this?

@dave11mj
Copy link

I think I found the solution: https://github.blog/2009-12-29-bypassing-jekyll-on-github-pages/

Doesn't seem to work for GH pages ... although I can confirm doing something like mv out/_next out/next serves the JS chunks / static file properly from GH pages.

@dave11mj
Copy link

I think I found the solution: https://github.blog/2009-12-29-bypassing-jekyll-on-github-pages/

Doesn't seem to work for GH pages ... although I can confirm doing something like mv out/_next out/next serves the JS chunks / static file properly from GH pages.

Btw ~ the .nojekyll works ! just make sure you have in the specific branch / repo before enabling github pages. In my case I had to delete the gh-pages branch and re-create it as gh-pages-deployed with the .nojekyll file then enable the github pages.

@jimisaacs
Copy link

Not allowing this to be configurable is turning out to be a blocker for me to use Next.js entirely.

@hiyelbaz
Copy link

hiyelbaz commented Mar 24, 2021

The underscore is breaking things for many use cases. I think it is worth to keep this issue open. Thanks.

@sayjeyhi
Copy link

any updates!? gh-pages is not working with _next folder name

@Angramme
Copy link

Angramme commented Jul 2, 2021

+1 allowing to change _next to another name would be really useful in many cases, or at least an option for the generator to exclude certain characters such as the underscore

@iammerrick
Copy link

Using Next + Static Export cannot be used to write a chrome extension because of this limitation.

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests