webpack.prod.minimize.config.js 1.1 KB

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