Tuesday, 25 April 2017

Does the order matter when including webpack chunks in a server response?

I'm converting my react app to a universal application (server side rendering). In my server response I'll need to include the assets bundled by webpack as well. When extracted with webpack-stats-plugin I get the following json:

{
  "assetsByChunkName": {
    "react": [
      "react.74aaea891aaffa48d257.js",
      "react.74aaea891aaffa48d257.js.map"
    ],
    "vendor": [
      "vendor.6aaf628afec42fad614d.js",
      "vendor-6aaf628afec42fad614d.css",
      "vendor.6aaf628afec42fad614d.js.map",
      "vendor-6aaf628afec42fad614d.css.map"
    ],
    "main": [
      "main.5eaef2a54c9a2a521141.js",
      "main-5eaef2a54c9a2a521141.css",
      "main.5eaef2a54c9a2a521141.js.map",
      "main-5eaef2a54c9a2a521141.css.map"
    ],
    "manifest": [
      "manifest.d41d8cd98f00b204e980.js",
      "manifest.d41d8cd98f00b204e980.js.map"
    ]
  }
}

I could parse through that and include all js at the end of the body, and all css at the head, but that would be assuming that the order doesn't matter. Does the order in which these scripts get added matter? If so, how do I make sure they always get added in the right order?



via vsjn3290ckjnaoij2jikndckjb

No comments:

Post a Comment