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.

33 lines
1.3 KiB

  1. const ManifestPlugin = require('webpack-manifest-plugin');
  2. const WorkboxWebpackPlugin = require('workbox-webpack-plugin');
  3. const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  4. const CompressionPlugin = require("compression-webpack-plugin");
  5. const path = require('path');
  6. const fs = require('fs');
  7. module.exports = function override(config, env) {
  8. if (env === "production") {
  9. // rename the ouput file, we need it's path to be short, for SPIFFS
  10. config.output.filename = 'js/[id].[chunkhash:4].js';
  11. config.output.chunkFilename = 'js/[id].[chunkhash:4].js';
  12. // take out the manifest and service worker plugins
  13. config.plugins = config.plugins.filter(plugin => !(plugin instanceof ManifestPlugin));
  14. config.plugins = config.plugins.filter(plugin => !(plugin instanceof WorkboxWebpackPlugin.GenerateSW));
  15. // shorten css filenames
  16. const miniCssExtractPlugin = config.plugins.find((plugin) => plugin instanceof MiniCssExtractPlugin);
  17. miniCssExtractPlugin.options.filename = "css/[id].[contenthash:4].css";
  18. miniCssExtractPlugin.options.chunkFilename = "css/[id].[contenthash:4].c.css";
  19. // add compression plugin, compress javascript
  20. config.plugins.push(new CompressionPlugin({
  21. filename: "[path].gz[query]",
  22. algorithm: "gzip",
  23. test: /\.(js)$/,
  24. deleteOriginalAssets: true
  25. }));
  26. }
  27. return config;
  28. }