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.config.js 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* global __dirname */
  2. const process = require('process');
  3. const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
  4. const analyzeBundle = process.argv.indexOf('--analyze-bundle') !== -1;
  5. const minimize
  6. = process.argv.indexOf('-p') !== -1
  7. || process.argv.indexOf('--optimize-minimize') !== -1;
  8. const config = {
  9. // The inline-source-map is used to allow debugging the unit tests with Karma
  10. devtool: minimize ? 'source-map' : 'inline-source-map',
  11. mode: minimize ? 'production' : 'development',
  12. module: {
  13. rules: [ {
  14. // Version this build of the lib-jitsi-meet library.
  15. loader: 'string-replace-loader',
  16. options: {
  17. flags: 'g',
  18. replace:
  19. process.env.LIB_JITSI_MEET_COMMIT_HASH || 'development',
  20. search: '{#COMMIT_HASH#}'
  21. },
  22. test: `${__dirname}/JitsiMeetJS.js`
  23. }, {
  24. // Transpile ES2015 (aka ES6) to ES5.
  25. exclude: [
  26. new RegExp(`${__dirname}/node_modules/(?!@jitsi/js-utils)`)
  27. ],
  28. loader: 'babel-loader',
  29. options: {
  30. presets: [
  31. [
  32. '@babel/preset-env',
  33. // Tell babel to avoid compiling imports into CommonJS
  34. // so that webpack may do tree shaking.
  35. {
  36. modules: false,
  37. // Specify our target browsers so no transpiling is
  38. // done unnecessarily. For browsers not specified
  39. // here, the ES2015+ profile will be used.
  40. targets: {
  41. chrome: 58,
  42. electron: 2,
  43. firefox: 54,
  44. safari: 11
  45. }
  46. }
  47. ],
  48. '@babel/preset-flow'
  49. ],
  50. plugins: [
  51. '@babel/plugin-transform-flow-strip-types',
  52. '@babel/plugin-proposal-class-properties',
  53. '@babel/plugin-proposal-export-namespace-from'
  54. ]
  55. },
  56. test: /\.js$/
  57. } ]
  58. },
  59. node: {
  60. // Allow the use of the real filename of the module being executed. By
  61. // default Webpack does not leak path-related information and provides a
  62. // value that is a mock (/index.js).
  63. __filename: true
  64. },
  65. optimization: {
  66. concatenateModules: minimize
  67. },
  68. output: {
  69. filename: `[name]${minimize ? '.min' : ''}.js`,
  70. path: process.cwd(),
  71. sourceMapFilename: `[name].${minimize ? 'min' : 'js'}.map`
  72. },
  73. performance: {
  74. hints: minimize ? 'error' : false,
  75. maxAssetSize: 750 * 1024,
  76. maxEntrypointSize: 750 * 1024
  77. },
  78. plugins: [
  79. analyzeBundle
  80. && new BundleAnalyzerPlugin({
  81. analyzerMode: 'disabled',
  82. generateStatsFile: true
  83. })
  84. ].filter(Boolean)
  85. };
  86. module.exports = [
  87. Object.assign({}, config, {
  88. entry: {
  89. 'lib-jitsi-meet': './index.js'
  90. },
  91. output: Object.assign({}, config.output, {
  92. library: 'JitsiMeetJS',
  93. libraryTarget: 'umd'
  94. })
  95. }),
  96. {
  97. entry: {
  98. worker: './modules/e2ee/Worker.js'
  99. },
  100. mode: 'production',
  101. output: {
  102. filename: 'lib-jitsi-meet.e2ee-worker.js',
  103. path: process.cwd()
  104. },
  105. optimization: {
  106. minimize: false
  107. }
  108. }
  109. ];