title: Document not defined on angular universal, changes wont get saved
body: <p>I've searched for an answer here but I couldn't get it to work yet.</p>
  
  <p>I get the following error-message when running "node dist/server.js"</p>
  
  <pre><code>ReferenceError: document is not defined
  at new BrowserPlatform (C:\cmder\Project\dist\server.js:164638:25)
  at Object.&lt;anonymous&gt; (C:\cmder\Project\dist\server.js:164682:29)
  at __webpack_require__ (C:\cmder\Project\dist\server.js:20:30)
  at Object.&lt;anonymous&gt; (C:\cmder\Project\dist\server.js:136679:77)
  at __webpack_require__ (C:\cmder\Project\dist\server.js:20:30)
  at Object.firebase (C:\cmder\Project\dist\server.js:123364:18)
  at __webpack_require__ (C:\cmder\Project\dist\server.js:120467:30)
  at Object../src/app/app.component.ts (C:\cmder\Project\dist\server.js:120652:16)
  at __webpack_require__ (C:\cmder\Project\dist\server.js:120467:30)
  at Object../src/app/app.server.module.ngfactory.js (C:\cmder\Project\dist\server.js:120708:10)
  </code></pre>
  
  <p>I've read that I should put an if statement around document (and window) in that case. Which I did in the dist/server.js file:</p>
  
  <pre><code>var BrowserPlatform = /** @class */ (function () {
  function BrowserPlatform() {
      this.emptyByteString = '';
      if(document) {this.document = document;}
      if(window) {this.window = window;}
      this.base64Available = typeof atob !== 'undefined';
  }
  </code></pre>
  
  <p>Now when I run "npm run webpack:server" these changes get removed, so I'm here with the original file with just "this.document = document;" and so on and the error remains the same once I go "node dist/server.js"</p>