Separate my html landing page from react app?
I want to have a separate set of HTML
pages from my react app.
I've created this vanilla HTML/ CSS/ JS
landing page that looks great. I'm trying to figure out how to make this my index page without actually adding it to my React
app.
This is because of the various plugins I'm using that doesn't translate to React
, and unique CSS
code that I'd rather not have global.
Imagine loading to the home page, which is vanilla HTML
. Then when the user hits the login button, it directs them to the React /login
component. I have the routing set up so that referencing /login
in an anchor will trigger React
, I just need to get the HTML
to be standalone.
Here's the way my app is currently set up.
reactapp
|
------server.js
|
------package.json
|
------boilerplate etc
|
------client
|
-------public
|
-----index.html
|
-------landingHomePage.html
|
--------src
|
-----index.js
|
-----page1.js, page2.js, page3.js etc
in reactapp/server.js
app.use(express.static(path.join(__dirname, "client/build")));
const port = process.env.PORT || 5000
console.log("PORT NUMBER IS " + port);
app.listen(port, () => console.log(`Server Running on port ${port}`));
in reactapp/package.json
{
"name": "reactexpress",
"version": "1.0.0",
"description": "react-express boilerplate",
"main": "server.js",
"scripts": {
"client-install": "npm install --prefix client",
"start": "node server.js",
"server": "nodemon server.js",
"client": "npm start --prefix client",
"dev": "concurrently "npm run server" "npm run client"",
"test": "echo "Error: no test specified" && exit 1",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
}, ...
in reactapp/client/src/index.js
ReactDOM.render(
<BrowserRouter>
<Layout>
<Switch>
<Route exact strict path={"/page1"} component={page1} />
<Route exact path={"/page2"} component={page2} />
<Route exact path={"/page3"} component={page3} />
<Route exact path={"/login"} component={Login}/>
</Switch>
</Layout>
</BrowserRouter>
, document.getElementById('root'));
The CURRENT index.html
is a standard HTML
empty template with
<div id="root"></div>
If I rename the current html to something like react.html
and rename landingHomePage.html
to index.html
, it gives errors.
Note: going to url/landingHomePage.html
DOES direct me to the right page without any issues, but I want this to be index.html
so it will go there by default.
javascript html node.js reactjs routing
add a comment |
I want to have a separate set of HTML
pages from my react app.
I've created this vanilla HTML/ CSS/ JS
landing page that looks great. I'm trying to figure out how to make this my index page without actually adding it to my React
app.
This is because of the various plugins I'm using that doesn't translate to React
, and unique CSS
code that I'd rather not have global.
Imagine loading to the home page, which is vanilla HTML
. Then when the user hits the login button, it directs them to the React /login
component. I have the routing set up so that referencing /login
in an anchor will trigger React
, I just need to get the HTML
to be standalone.
Here's the way my app is currently set up.
reactapp
|
------server.js
|
------package.json
|
------boilerplate etc
|
------client
|
-------public
|
-----index.html
|
-------landingHomePage.html
|
--------src
|
-----index.js
|
-----page1.js, page2.js, page3.js etc
in reactapp/server.js
app.use(express.static(path.join(__dirname, "client/build")));
const port = process.env.PORT || 5000
console.log("PORT NUMBER IS " + port);
app.listen(port, () => console.log(`Server Running on port ${port}`));
in reactapp/package.json
{
"name": "reactexpress",
"version": "1.0.0",
"description": "react-express boilerplate",
"main": "server.js",
"scripts": {
"client-install": "npm install --prefix client",
"start": "node server.js",
"server": "nodemon server.js",
"client": "npm start --prefix client",
"dev": "concurrently "npm run server" "npm run client"",
"test": "echo "Error: no test specified" && exit 1",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
}, ...
in reactapp/client/src/index.js
ReactDOM.render(
<BrowserRouter>
<Layout>
<Switch>
<Route exact strict path={"/page1"} component={page1} />
<Route exact path={"/page2"} component={page2} />
<Route exact path={"/page3"} component={page3} />
<Route exact path={"/login"} component={Login}/>
</Switch>
</Layout>
</BrowserRouter>
, document.getElementById('root'));
The CURRENT index.html
is a standard HTML
empty template with
<div id="root"></div>
If I rename the current html to something like react.html
and rename landingHomePage.html
to index.html
, it gives errors.
Note: going to url/landingHomePage.html
DOES direct me to the right page without any issues, but I want this to be index.html
so it will go there by default.
javascript html node.js reactjs routing
What erros does it give you?
– Slawomir Wozniak
Jan 1 at 15:28
add a comment |
I want to have a separate set of HTML
pages from my react app.
I've created this vanilla HTML/ CSS/ JS
landing page that looks great. I'm trying to figure out how to make this my index page without actually adding it to my React
app.
This is because of the various plugins I'm using that doesn't translate to React
, and unique CSS
code that I'd rather not have global.
Imagine loading to the home page, which is vanilla HTML
. Then when the user hits the login button, it directs them to the React /login
component. I have the routing set up so that referencing /login
in an anchor will trigger React
, I just need to get the HTML
to be standalone.
Here's the way my app is currently set up.
reactapp
|
------server.js
|
------package.json
|
------boilerplate etc
|
------client
|
-------public
|
-----index.html
|
-------landingHomePage.html
|
--------src
|
-----index.js
|
-----page1.js, page2.js, page3.js etc
in reactapp/server.js
app.use(express.static(path.join(__dirname, "client/build")));
const port = process.env.PORT || 5000
console.log("PORT NUMBER IS " + port);
app.listen(port, () => console.log(`Server Running on port ${port}`));
in reactapp/package.json
{
"name": "reactexpress",
"version": "1.0.0",
"description": "react-express boilerplate",
"main": "server.js",
"scripts": {
"client-install": "npm install --prefix client",
"start": "node server.js",
"server": "nodemon server.js",
"client": "npm start --prefix client",
"dev": "concurrently "npm run server" "npm run client"",
"test": "echo "Error: no test specified" && exit 1",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
}, ...
in reactapp/client/src/index.js
ReactDOM.render(
<BrowserRouter>
<Layout>
<Switch>
<Route exact strict path={"/page1"} component={page1} />
<Route exact path={"/page2"} component={page2} />
<Route exact path={"/page3"} component={page3} />
<Route exact path={"/login"} component={Login}/>
</Switch>
</Layout>
</BrowserRouter>
, document.getElementById('root'));
The CURRENT index.html
is a standard HTML
empty template with
<div id="root"></div>
If I rename the current html to something like react.html
and rename landingHomePage.html
to index.html
, it gives errors.
Note: going to url/landingHomePage.html
DOES direct me to the right page without any issues, but I want this to be index.html
so it will go there by default.
javascript html node.js reactjs routing
I want to have a separate set of HTML
pages from my react app.
I've created this vanilla HTML/ CSS/ JS
landing page that looks great. I'm trying to figure out how to make this my index page without actually adding it to my React
app.
This is because of the various plugins I'm using that doesn't translate to React
, and unique CSS
code that I'd rather not have global.
Imagine loading to the home page, which is vanilla HTML
. Then when the user hits the login button, it directs them to the React /login
component. I have the routing set up so that referencing /login
in an anchor will trigger React
, I just need to get the HTML
to be standalone.
Here's the way my app is currently set up.
reactapp
|
------server.js
|
------package.json
|
------boilerplate etc
|
------client
|
-------public
|
-----index.html
|
-------landingHomePage.html
|
--------src
|
-----index.js
|
-----page1.js, page2.js, page3.js etc
in reactapp/server.js
app.use(express.static(path.join(__dirname, "client/build")));
const port = process.env.PORT || 5000
console.log("PORT NUMBER IS " + port);
app.listen(port, () => console.log(`Server Running on port ${port}`));
in reactapp/package.json
{
"name": "reactexpress",
"version": "1.0.0",
"description": "react-express boilerplate",
"main": "server.js",
"scripts": {
"client-install": "npm install --prefix client",
"start": "node server.js",
"server": "nodemon server.js",
"client": "npm start --prefix client",
"dev": "concurrently "npm run server" "npm run client"",
"test": "echo "Error: no test specified" && exit 1",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
}, ...
in reactapp/client/src/index.js
ReactDOM.render(
<BrowserRouter>
<Layout>
<Switch>
<Route exact strict path={"/page1"} component={page1} />
<Route exact path={"/page2"} component={page2} />
<Route exact path={"/page3"} component={page3} />
<Route exact path={"/login"} component={Login}/>
</Switch>
</Layout>
</BrowserRouter>
, document.getElementById('root'));
The CURRENT index.html
is a standard HTML
empty template with
<div id="root"></div>
If I rename the current html to something like react.html
and rename landingHomePage.html
to index.html
, it gives errors.
Note: going to url/landingHomePage.html
DOES direct me to the right page without any issues, but I want this to be index.html
so it will go there by default.
javascript html node.js reactjs routing
javascript html node.js reactjs routing
edited Dec 29 '18 at 18:58
slashburn
2,26212141
2,26212141
asked Dec 29 '18 at 2:32
Alexander GonzalezAlexander Gonzalez
83
83
What erros does it give you?
– Slawomir Wozniak
Jan 1 at 15:28
add a comment |
What erros does it give you?
– Slawomir Wozniak
Jan 1 at 15:28
What erros does it give you?
– Slawomir Wozniak
Jan 1 at 15:28
What erros does it give you?
– Slawomir Wozniak
Jan 1 at 15:28
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53966216%2fseparate-my-html-landing-page-from-react-app%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53966216%2fseparate-my-html-landing-page-from-react-app%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What erros does it give you?
– Slawomir Wozniak
Jan 1 at 15:28