Webpack plugin that generates a service worker using sw-precache that will cache webpack's bundles' emitted assets. You can optionally pass sw-precache configuration options to webpack through this plugin.
MIT License
1.44k
stars
104
forks
source link
Using this module breaks the JSON emitted by webpack --profile #122
the problem:
This plugin logs the following: Total precache size is about 1.68 MB for 46 resources., which ends up in the bundle stats json, resulting in an invalid json file.
Modify the example, webpack script in package.json by adding --profile --json > webpack.stats.json.
It should look like this: "webpack": "NODE_ENV=production ./node_modules/.bin/webpack --config=webpack.config.js --progress --profile --json > webpack.stats.json"
run the script with npm run webpack
check the generated webpack.stats.json file, it will be corrupted, with the first line being: Total precache size is about 847 kB for 2 resources.
webpack version: 3.8.1
sw-precache-webpack-plugin version: 0.11.4
Please tell us about your environment: OSX, Node 8.2.1
Current behavior:
context: Webpack allows to create a profile of the app with the profile option. This profile is a json having stats that can be consumed by tools like webpack-bundle-analyzer.
the problem: This plugin logs the following:
Total precache size is about 1.68 MB for 46 resources.
, which ends up in the bundle stats json, resulting in an invalid json file.The logged message is actually emitted by sw-precache, here.
Expected/desired behavior:
This message should not end up in the stats.json file.
How to reproduce
You can use the example of sw-precache-webpack-plugin repo. (this repo).
Modify the example, webpack script in package.json by adding
--profile --json > webpack.stats.json
. It should look like this:"webpack": "NODE_ENV=production ./node_modules/.bin/webpack --config=webpack.config.js --progress --profile --json > webpack.stats.json"
run the script with
npm run webpack
check the generated webpack.stats.json file, it will be corrupted, with the first line being:
Total precache size is about 847 kB for 2 resources.