title: How to integrate Webpack in a multi-page PHP application
body: <p>I'm working on an old Codeigniter website where the Javascript codebase is messy and poorly structured and I would like to use Webback to manage the scripts. My goal would be start using it to bundle the code I have the way it is, and gradually refactoring it to make use of modules and imports.</p>
  
  <p>At the moment I'm using Gulp on development (but mostly to minify the files) and <a href="https://github.com/bcit-ci/CodeIgniter/wiki/Carabiner" rel="nofollow noreferrer">Carabiner</a> (a Codeigniter library) to insert the scripts in the views.</p>
  
  <p>The scripts, which are all written as IIFEs are not bundled, so in every controller function I have an array of the scripts needed in that page. For example:</p>
  
  <pre><code>public function homepage()
  {
      $this-&gt;carabiner-&gt;js([
          ['libraryThatIOnlyNeedHere.min.js'],
          ['myscript1.js'],
          ['myscript2.js'],
          ['myscript3.js'],
      ]);
  </code></pre>
  
  <p>I would like to use Webpack to create a series of bundles so that I end up loading maximum two files on every page: one for the libraries and one for my scripts.</p>
  
  <p>All the practical examples I've seen with Webpack, though, are for Single Page Applications where it's quite easy to bundle everything together.</p>
  
  <p>What would be the best approach in my case? Considering that the code is still not ready to properly use modules and imports, shall I create many entry points in the Webpack configuration file, possibly one for every page and list every script needed in that page?</p>