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.

37 lines
1.5 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 ProgmemGenerator = require('./progmem-generator.js');
  6. const path = require('path');
  7. const fs = require('fs');
  8. module.exports = function override(config, env) {
  9. if (env === "production") {
  10. // rename the ouput file, we need it's path to be short, for SPIFFS
  11. config.output.filename = 'js/[id].[chunkhash:4].js';
  12. config.output.chunkFilename = 'js/[id].[chunkhash:4].js';
  13. // take out the manifest and service worker plugins
  14. config.plugins = config.plugins.filter(plugin => !(plugin instanceof ManifestPlugin));
  15. config.plugins = config.plugins.filter(plugin => !(plugin instanceof WorkboxWebpackPlugin.GenerateSW));
  16. // shorten css filenames
  17. const miniCssExtractPlugin = config.plugins.find((plugin) => plugin instanceof MiniCssExtractPlugin);
  18. miniCssExtractPlugin.options.filename = "css/[id].[contenthash:4].css";
  19. miniCssExtractPlugin.options.chunkFilename = "css/[id].[contenthash:4].c.css";
  20. // build progmem data files
  21. config.plugins.push(new ProgmemGenerator({ outputPath: "../lib/framework/WWWData.h", bytesPerLine: 20 }));
  22. // add compression plugin, compress javascript
  23. config.plugins.push(new CompressionPlugin({
  24. filename: "[path].gz[query]",
  25. algorithm: "gzip",
  26. test: /\.(js)$/,
  27. deleteOriginalAssets: true
  28. }));
  29. }
  30. return config;
  31. }