title: How to add react to an existing express multipage project with ejs?
body: <p>I have an existing multi-page app with ejs templating, however, I would like to use React in one of the pages.</p>
  
  <p>Is it possible to mix the two using webpack?</p>
  
  <p>For instance, i'd like all the content on my current page to stay the same, but use React for a particular div </p>
  
  <p>I am able to bundle my react files with webpack, however, not able to link it to  tag so as to make this work. Any help would be appreciated.</p>
  
  <p>Here is my webpack config file:</p>
  
  <pre><code>const path = require("path");
  
  const outputDirectory = "dist";
  
  module.exports = {
    entry: "./src/react/index.js",
    output: {
      path: path.join(__dirname, outputDirectory),
      filename: "bundle.js"
    },
    module: {
      rules: [
        {
          test: /\.js$/,
          exclude: /node_modules/,
          use: {
            loader: "babel-loader"
          }
        },
        {
          test: /\.css$/,
          use: ["style-loader", "css-loader"]
        },
        {
          test: /\.(png|woff|woff2|eot|ttf|svg)$/,
          loader: "url-loader?limit=100000"
        }
      ]
    },
    devServer: {
      port: 3000
    }
  };
  </code></pre>
  
  <p>I have found a way to do this by generating a production build everytime, and linking the dist bundle.js to my script file in the ejs served by express.</p>
  
  <p>However, I am fairly certain that this can be done in a better fashion but unable to find a way to do it.</p>