add offline-plugin

This commit is contained in:
Kent C. Dodds 2016-07-05 00:23:35 -06:00
parent 720e4718b5
commit 969f8cb86f
3 changed files with 12 additions and 0 deletions

View File

@ -34,6 +34,7 @@
"karma-webpack": "1.7.0",
"mocha": "3.0.1",
"npm-run-all": "2.3.0",
"offline-plugin": "3.4.2",
"opt-cli": "1.5.1",
"progress-bar-webpack-plugin": "1.9.0",
"rimraf": "2.5.4",

4
src/bootstrap.js vendored
View File

@ -1,4 +1,5 @@
/* eslint no-console:0 */
import {install as offlineInstall} from 'offline-plugin/runtime'
import {onLoad} from './app'
import {$on} from './helpers'
@ -24,4 +25,7 @@ if (module.hot) {
function bootstrap() {
$on(window, 'load', onLoad)
$on(window, 'hashchange', onLoad)
if (process.env.NODE_ENV === 'production') {
offlineInstall()
}
}

View File

@ -7,6 +7,7 @@ const InlineManifestWebpackPlugin = require('inline-manifest-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const webpackValidator = require('webpack-validator')
const {getIfUtils, removeEmpty} = require('webpack-config-utils')
const OfflinePlugin = require('offline-plugin')
module.exports = env => {
const {ifProd, ifNotProd} = getIfUtils(env)
@ -45,6 +46,12 @@ module.exports = env => {
template: './index.html',
inject: 'head',
}),
new OfflinePlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: ifProd('"production"', '"development"')
}
}),
]),
})
if (env.debug) {