modified lib-jitsi-meet dev repo
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.

webpack-shared-config.js 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* global __dirname */
  2. const path = require('path');
  3. const process = require('process');
  4. const { ProvidePlugin } = require('webpack');
  5. const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
  6. module.exports = (minimize, analyzeBundle) => {
  7. return {
  8. // The inline-source-map is used to allow debugging the unit tests with Karma
  9. devtool: minimize ? 'source-map' : 'inline-source-map',
  10. resolve: {
  11. alias: {
  12. 'jquery': require.resolve('jquery/dist/jquery.slim.min.js')
  13. },
  14. extensions: [ '', '.js', '.ts' ]
  15. },
  16. mode: minimize ? 'production' : 'development',
  17. module: {
  18. rules: [ {
  19. // Version this build of the lib-jitsi-meet library.
  20. loader: 'string-replace-loader',
  21. options: {
  22. flags: 'g',
  23. replace:
  24. process.env.LIB_JITSI_MEET_COMMIT_HASH || 'development',
  25. search: '{#COMMIT_HASH#}'
  26. },
  27. test: path.join(__dirname, 'JitsiMeetJS.ts')
  28. }, {
  29. // Transpile ES2015 (aka ES6) to ES5.
  30. loader: 'babel-loader',
  31. options: {
  32. presets: [
  33. [
  34. '@babel/preset-env',
  35. // Tell babel to avoid compiling imports into CommonJS
  36. // so that webpack may do tree shaking.
  37. {
  38. modules: false,
  39. // Specify our target browsers so no transpiling is
  40. // done unnecessarily. For browsers not specified
  41. // here, the ES2015+ profile will be used.
  42. targets: {
  43. chrome: 80,
  44. electron: 10,
  45. firefox: 68,
  46. safari: 14
  47. }
  48. }
  49. ],
  50. '@babel/preset-typescript'
  51. ]
  52. },
  53. test: /\.(js|ts)$/
  54. } ]
  55. },
  56. node: {
  57. // Allow the use of the real filename of the module being executed. By
  58. // default Webpack does not leak path-related information and provides a
  59. // value that is a mock (/index.js).
  60. __filename: true
  61. },
  62. optimization: {
  63. concatenateModules: minimize
  64. },
  65. output: {
  66. filename: `[name]${minimize ? '.min' : ''}.js`,
  67. sourceMapFilename: `[name].${minimize ? 'min' : 'js'}.map`
  68. },
  69. performance: {
  70. hints: minimize ? 'error' : false,
  71. maxAssetSize: 825 * 1024,
  72. maxEntrypointSize: 825 * 1024
  73. },
  74. plugins: [
  75. analyzeBundle
  76. && new BundleAnalyzerPlugin({
  77. analyzerMode: 'disabled',
  78. generateStatsFile: true
  79. }),
  80. !minimize
  81. && new ProvidePlugin({
  82. process: require.resolve('process/browser')
  83. })
  84. ].filter(Boolean)
  85. };
  86. };