Fork of the excellent esp8266-react - https://github.com/rjwats/esp8266-react
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
1.0 KiB

  1. const CompressionPlugin = require("compression-webpack-plugin");
  2. const ManifestPlugin = require('webpack-manifest-plugin');
  3. const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
  4. const path = require('path');
  5. const fs = require('fs');
  6. module.exports = function override(config, env) {
  7. if (env === "production") {
  8. // rename the ouput file, we need it's path to be short, for SPIFFS
  9. config.output.filename = 'js/[name].[chunkhash:4].js';
  10. // disable sourcemap for production build
  11. config.devtool = false;
  12. // take out the manifest and service worker
  13. config.plugins = config.plugins.filter(plugin => !(plugin instanceof ManifestPlugin));
  14. config.plugins = config.plugins.filter(plugin => !(plugin instanceof SWPrecacheWebpackPlugin));
  15. // add compression plugin, compress javascript, html and css
  16. config.plugins.push(new CompressionPlugin({
  17. asset: "[path].gz[query]",
  18. algorithm: "gzip",
  19. test: /\.(js|html|css)$/,
  20. deleteOriginalAssets: true
  21. }));
  22. }
  23. return config;
  24. }