r-park / todo-react-redux

Todo app with Create-React-App • React-Redux • Firebase • OAuth
https://todo-react-redux.firebaseapp.com
MIT License
1.02k stars 272 forks source link

How to preserve ejs templating so can isomorphically render #49

Closed morgs32 closed 8 years ago

morgs32 commented 8 years ago

Hi again,

So here is my other question. I'd like to go isomorphic with your starter. This means using ejs (or any other templating language I presume). However, again htmlwebpackplugin gets in the way. It wants to compile the template (with lodash/underscore) as part of the webpack. I need it to leave the ejs templating language alone, so I can have it in the build.

Any thoughts?

Here's a screenshot: image

And here's the place in my commit where I isomorphically get the html. https://github.com/morgs32/morgans-tt/blob/master/server/main.js#L116

Thanks man. If you put one of those "buy me a coffee" widgets in the readme i'd use it in a heartbeat. but i know that's not for everyone.

morgs32 commented 8 years ago

To clarify, the reason this isn't a deal breaker is because I still use the index.html to in dev. The one at src/index.html. I just flat out ignore the one that gets put into target/index.html when running this in prod. Which means if I ever want to add analytics scripts, etc, to the index.html/ejs I've got to duplicate it. So, it's not a blocker. But it kept me up last night, that's all!

r-park commented 8 years ago

@morgs32 since you're reading the build artifacts from ./target and manually injecting them into the index.ejs, you don't need HtmlWebpackPlugin.

Take a look at assets-webpack-plugin — it will output a json file containing the paths to all of the assets processed by webpack, like this:

{
  "main": {
    "js": "/main.b0e19d8dae0ab7517c85.js",
    "css":"/styles.css"
  },
  "vendor": {
    "js": "/vendor.180e59abb104f0e8ed62.js"
  }
}