From 75d37cbdafafd98780c90acd1113099fd688901c Mon Sep 17 00:00:00 2001 From: NGPixel Date: Sat, 27 Jan 2018 22:06:18 -0500 Subject: [PATCH] feat: added offline-plugin --- client/index.js | 1 + dev/webpack/webpack.prod.js | 12 ++++++++++++ package.json | 1 + yarn.lock | 16 +++++++++++++--- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/client/index.js b/client/index.js index 4a846923..2db5f239 100644 --- a/client/index.js +++ b/client/index.js @@ -2,4 +2,5 @@ require('./scss/app.scss') require('./js/compatibility.js') +require('offline-plugin/runtime').install() require('./js/app.js') diff --git a/dev/webpack/webpack.prod.js b/dev/webpack/webpack.prod.js index e02738d5..39741213 100644 --- a/dev/webpack/webpack.prod.js +++ b/dev/webpack/webpack.prod.js @@ -4,6 +4,7 @@ const merge = require('webpack-merge') const CleanWebpackPlugin = require('clean-webpack-plugin') const UglifyJSPlugin = require('uglifyjs-webpack-plugin') const ExtractTextPlugin = require('extract-text-webpack-plugin') +const OfflinePlugin = require('offline-plugin') const DuplicatePackageCheckerPlugin = require('duplicate-package-checker-webpack-plugin') const common = require('./webpack.common.js') @@ -21,6 +22,17 @@ module.exports = merge(common, { 'process.env.NODE_ENV': JSON.stringify('production') }), new ExtractTextPlugin('css/bundle.css'), + new OfflinePlugin({ + caches: { + main: [ + 'js/runtime.js', + 'js/vendor.js', + 'js/client.js' + ], + additional: [':externals:'], + optional: ['*.chunk.js'] + } + }), new DuplicatePackageCheckerPlugin() ] }) diff --git a/package.json b/package.json index ff9300cd..21fff9ef 100644 --- a/package.json +++ b/package.json @@ -177,6 +177,7 @@ "node-dev": "3.1.3", "node-sass": "4.7.2", "nodemon": "1.14.11", + "offline-plugin": "4.9.0", "postcss-loader": "2.0.10", "postcss-selector-parser": "3.1.1", "progress-bar-webpack-plugin": "1.10.0", diff --git a/yarn.lock b/yarn.lock index 25e6de33..1339135f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3022,7 +3022,7 @@ decompress-response@^3.2.0: dependencies: mimic-response "^1.0.0" -deep-extend@~0.4.0, deep-extend@~0.4.1: +deep-extend@^0.4.0, deep-extend@~0.4.0, deep-extend@~0.4.1: version "0.4.2" resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.2.tgz#48b699c27e334bf89f10892be432f6e4c7d34a7f" @@ -3329,7 +3329,7 @@ ee-first@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" -ejs@^2.5.6: +ejs@^2.3.4, ejs@^2.5.6: version "2.5.7" resolved "https://registry.yarnpkg.com/ejs/-/ejs-2.5.7.tgz#cc872c168880ae3c7189762fd5ffc00896c9518a" @@ -6260,7 +6260,7 @@ loader-runner@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-2.3.0.tgz#f482aea82d543e07921700d5a46ef26fdac6b8a2" -loader-utils@^0.2.15: +loader-utils@0.2.x, loader-utils@^0.2.15: version "0.2.17" resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-0.2.17.tgz#f86e6374d43205a6e6c60e9196f17c0299bfb348" dependencies: @@ -7408,6 +7408,16 @@ object.pick@^1.3.0: dependencies: isobject "^3.0.1" +offline-plugin@4.9.0: + version "4.9.0" + resolved "https://registry.yarnpkg.com/offline-plugin/-/offline-plugin-4.9.0.tgz#0874960c0cb0c249f96b7cfc674217934660ed5c" + dependencies: + deep-extend "^0.4.0" + ejs "^2.3.4" + loader-utils "0.2.x" + minimatch "^3.0.3" + slash "^1.0.0" + on-finished@^2.3.0, on-finished@~2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947"