{"id":2598,"date":"2018-01-11T16:46:34","date_gmt":"2018-01-11T16:46:34","guid":{"rendered":"https:\/\/www.anagram.at\/?p=2598"},"modified":"2018-01-11T17:06:56","modified_gmt":"2018-01-11T17:06:56","slug":"ionic-cache-busting-webpack","status":"publish","type":"post","link":"https:\/\/www.anagram.at\/en\/ionic-cache-busting-webpack\/","title":{"rendered":"Ionic cache busting &#8211; Webpack"},"content":{"rendered":"<p>Out of the box, ionic webpack generates [nr].js files. When running in a browser these files are most probably cached.\u00a0The following text explains a not perfectly dry but still reasonable solution.<\/p>\n<p>First copy<br \/>\n<code>node_modules\\@ionic\\app-scripts\\config<\/code><br \/>\nto a the config folder of your app. Change the generated name and add a random (or not so random) string, i used the version identifier<\/p>\n<pre>\n...\nvar versionNr = 'v0.0.1';\n... \nvar prodConfig = {\n  entry: process.env.IONIC_APP_ENTRY_POINT,\n  output: {\n    ...\n    filename: '[name]-' + versionNr + '.js',\n    devtoolModuleFilenameTemplate: ionicWebpackFactory.getSourceMapperFunction(),\n  },\n  ... \n  \/\/ do the same for devConfig \n  ...\n<\/pre>\n<p>In your package.json configure webpack to use the file you changed<\/p>\n<pre>{\n    \"name\": \"my-awesome-app\",\n    \"version\": \"0.0.1\",\n    \"author\": \"Anagram Engineering\",\n    \"homepage\": \"http:\/\/anagram.at\/\",\n    \"private\": true,\n    \"config\": {\n        \"ionic_copy\": \".\/config\/copy.config.js\", \/\/ a custom copy scripts - not required \n        \"ionic_webpack\": \".\/config\/webpack.config.js\" \/\/ tell ionic to use the adapted webpack configuration\n    },\n<\/pre>\n<p>You will also need to change the index.html an tell it to use the generated version<\/p>\n<pre>   \n    ... script src=\"build\/polyfills.js\" ...\n    ... script src=\"build\/vendor-v0.0.1.js\" ...\n    ... script src=\"build\/main-v0.0.1.js\" ...\n<\/pre>\n<p>This is working with partials and lazy loading enabled.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Out of the box, ionic webpack generates [nr].js files. When running in a browser these files are most probably cached.\u00a0The following text explains a not perfectly dry but still reasonable solution. First copy node_modules\\@ionic\\app-scripts\\config to a the config folder of your app. Change the generated name and add a random (or not so random) string, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":""},"categories":[9],"tags":[],"featured_image_src":null,"featured_image_src_square":null,"author_info":{"display_name":"Harald","author_link":"https:\/\/www.anagram.at\/en\/author\/admin\/"},"_links":{"self":[{"href":"https:\/\/www.anagram.at\/en\/wp-json\/wp\/v2\/posts\/2598"}],"collection":[{"href":"https:\/\/www.anagram.at\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.anagram.at\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.anagram.at\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.anagram.at\/en\/wp-json\/wp\/v2\/comments?post=2598"}],"version-history":[{"count":3,"href":"https:\/\/www.anagram.at\/en\/wp-json\/wp\/v2\/posts\/2598\/revisions"}],"predecessor-version":[{"id":2607,"href":"https:\/\/www.anagram.at\/en\/wp-json\/wp\/v2\/posts\/2598\/revisions\/2607"}],"wp:attachment":[{"href":"https:\/\/www.anagram.at\/en\/wp-json\/wp\/v2\/media?parent=2598"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.anagram.at\/en\/wp-json\/wp\/v2\/categories?post=2598"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.anagram.at\/en\/wp-json\/wp\/v2\/tags?post=2598"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}