Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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