webpack.prod.minimize.config.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. const TerserPlugin = require('terser-webpack-plugin');
  2. const merge = require('webpack-merge').default;
  3. const LicenseWebpackPlugin = require('license-webpack-plugin')
  4. .LicenseWebpackPlugin;
  5. const config = require('./webpack.config');
  6. config[0] = merge(config[0], {
  7. mode: 'production',
  8. devtool: 'source-map',
  9. output: {
  10. // Add version argument when in production so the Jupyter server
  11. // allows caching of files (i.e., does not set the CacheControl header to no-cache to prevent caching static files)
  12. filename: '[name].[contenthash].js?v=[contenthash]'
  13. },
  14. optimization: {
  15. minimize: true,
  16. minimizer: [
  17. new TerserPlugin({
  18. parallel: true,
  19. sourceMap: true,
  20. terserOptions: {
  21. compress: false,
  22. ecma: 6,
  23. mangle: true,
  24. output: {
  25. beautify: false,
  26. comments: false
  27. },
  28. safari10: true
  29. },
  30. cache: process.platform !== 'win32'
  31. })
  32. ]
  33. },
  34. plugins: [
  35. new LicenseWebpackPlugin({
  36. perChunkOutput: false,
  37. outputFilename: 'third-party-licenses.txt',
  38. excludedPackageTest: packageName =>
  39. packageName === '@jupyterlab/application-top'
  40. })
  41. ]
  42. });
  43. module.exports = config;