Skip to content

Instantly share code, notes, and snippets.

@pekkis
Created October 22, 2018 06:42
Show Gist options
  • Save pekkis/b9c5c289f0dabb4b10589f8b0d000a64 to your computer and use it in GitHub Desktop.
Save pekkis/b9c5c289f0dabb4b10589f8b0d000a64 to your computer and use it in GitHub Desktop.
const myFeature = require("./src/config/workboxFeature");
addFeatures(
...,
myFeature,
)
// src/config/workboxFeature.js
const { OrderedSet, fromJS, List } = require("immutable");
const {
createFeature,
createPlugin
} = require("@dr-kobros/broilerplate/lib/extend");
const Plugin = require("workbox-webpack-plugin");
const path = require("path");
const workboxInjectPlugin = createPlugin(Plugin.InjectManifest)({
name: () => "workboxInjectPlugin",
isEnabled: (env, target) => target === "client",
options: (env, target, paths) => {
return List.of(
fromJS({
swSrc: path.resolve(paths.get("src"), "./sw.js")
})
);
}
});
const workboxFeature = createFeature({
name: () => "workboxFeature",
loaders: () => OrderedSet.of(),
plugins: () => OrderedSet.of(workboxInjectPlugin)
});
module.exports = workboxFeature;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment