don't set cache header on serviceWorker.js

This commit is contained in:
Danny Coates 2018-07-12 20:48:07 -07:00
parent 5677390a45
commit 1a78f57515
No known key found for this signature in database
GPG Key ID: 4C442633C62E00CB
4 changed files with 4117 additions and 8726 deletions

View File

@ -19,8 +19,6 @@ function kv(f) {
module.exports = function() {
const files = fs.readdirSync(path.join(__dirname, '..', 'assets'));
const code = `module.exports = {
"package.json": require('../package.json'),
"serviceWorker.js" : require('../app/serviceWorker.js'),
${files.map(kv).join(',\n')}
};`;
return {

18875
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -18,8 +18,10 @@ routes(app);
app.use(
express.static(path.resolve(__dirname, '../../dist/'), {
setHeaders: function(res) {
setHeaders: function(res, path) {
if (!/serviceWorker\.js$/.test(path)) {
res.set('Cache-Control', 'public, max-age=31536000, immutable');
}
res.removeHeader('Pragma');
}
})

View File

@ -3,7 +3,7 @@ const webpack = require('webpack');
const CopyPlugin = require('copy-webpack-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
const VersionPlugin = require('./build/version_plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const webJsOptions = {
babelrc: false,
@ -12,6 +12,18 @@ const webJsOptions = {
plugins: ['yo-yoify']
};
const serviceWorker = {
target: 'webworker',
entry: {
serviceWorker: './app/serviceWorker.js'
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/'
}
};
const web = {
target: 'web',
entry: {
@ -193,29 +205,19 @@ const web = {
}
};
const serviceWorker = {
target: 'webworker',
entry: {
serviceWorker: './app/serviceWorker.js'
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/'
}
}
module.exports = (env, argv) => {
module.exports = () => {
//(env, argv) => {
// TODO: why are styles not output in 'production' mode?
const mode = 'development' //argv.mode || 'production';
const mode = 'development'; //argv.mode || 'production';
console.error(`mode: ${mode}`);
web.mode = serviceWorker.mode = mode;
if (mode === 'development') {
web.devtool = 'inline-source-map';
web.devServer.before = require('./server/bin/dev');
web.entry.tests = ['./test/frontend/index.js'];
// istanbul instruments the source for code coverage
webJsOptions.plugins.push('istanbul');
web.devServer.before = require('./server/bin/dev');
web.entry.tests = ['./test/frontend/index.js'];
web.devtool = 'inline-source-map';
serviceWorker.devtool = 'inline-source-map';
}
return [web, serviceWorker]
}
return [serviceWorker, web];
};