react-firebase-starter icon indicating copy to clipboard operation
react-firebase-starter copied to clipboard

Help for publishing without server

Open psamim opened this issue 9 years ago • 6 comments
trafficstars

Hi,

Is it possible to publish the Website in way to use it without any server and use just the browser? Currently when I build (node run build --release), the resulting files are static but need / as their path (a static file server is needed).

I know the issues are just for reporting issues but I would appreciate if someone could help.

Thanks, Samim

psamim avatar Oct 24 '16 13:10 psamim

Have you seen https://github.com/kriasoft/react-starter-kit/pull/642 ? Is this exactly what you need?

frenzzy avatar Oct 24 '16 14:10 frenzzy

Not exactly, the above generates files for every route. I meant having one index.html file that can be opened with browser without having any static file server.

I have built my project with react-static-boilerplate and I do not have the knowledge to switch to react-starter-kit.

Now when I build my project I can use it with a server, but not I cannot use it by directly opening the index.html file with a browser. I would be very grateful if you could give me some clues what to do.

psamim avatar Oct 24 '16 21:10 psamim

@frenzzy Maybe the problem is with history, I get the following in the console:

Uncaught SecurityError: Failed to execute 'pushState' on 'History': A history state object with URL 'file:///' cannot be created in a document with origin 'null' and URL 'file:///home/...````

psamim avatar Oct 25 '16 06:10 psamim

@psamim even if you open index.html in a browser, it references images and .js files, how the HTML page would load them without a server?

You could try to embed everything into the application bundle (main.js) and then embed that JavaScript code into your HTML page so that the build output folder would contain just a single index.html file. If you do so, it may work without a server.

For example instead of <script src="/main.js"></script> there will be <script>/* application code */</script>. Also learn more about file-loader plugin for Webpack that helps embedding images and CSS into the application bundle. Instead of HTML5 History API you would need to use window.onhashchange event listener and hash-based URLs. For example, instead of links such as <Link to="/products/123">..</Link> it would suffice to use regular anchor tags <a href="/#/products/123">...</a>.

koistya avatar Oct 25 '16 06:10 koistya

Not exactly, the above generates files for every route. I meant having one index.html file that can be opened with browser without having any static file server. I have built my project with react-static-boilerplate and I do not have the knowledge to switch to react-starter-kit. Now when I build my project I can use it with a server, but not I cannot use it by directly opening the index.html file with a browser. I would be very grateful if you could give me some clues what to do.

On Mon, Oct 24, 2016, 5:41 PM Vladimir Kutepov [email protected] wrote:

Have you seen kriasoft/react-starter-kit#642 https://github.com/kriasoft/react-starter-kit/pull/642 ? Is this exactly what you need?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kriasoft/react-static-boilerplate/issues/163#issuecomment-255751355, or mute the thread https://github.com/notifications/unsubscribe-auth/AByDhxhCOiB6jM6MAtyaRTGuImgPWtcCks5q3LxzgaJpZM4KeyAg .

psamim avatar Oct 25 '16 18:10 psamim

I keep finding this thread when searching for why my local copy doesn't produce html files, only js files + images, and when I deploy it says Page Not Found on the deployed firebase servers. Is this releated?

signalprime avatar Jul 18 '19 22:07 signalprime