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 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* global __dirname */
  2. const process = require('process');
  3. const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
  4. const webpack = require('webpack');
  5. const minimize
  6. = process.argv.indexOf('-p') !== -1
  7. || process.argv.indexOf('--optimize-minimize') !== -1;
  8. const plugins = [
  9. new webpack.LoaderOptionsPlugin({
  10. debug: !minimize,
  11. minimize
  12. })
  13. ];
  14. if (minimize) {
  15. plugins.push(new webpack.optimize.ModuleConcatenationPlugin());
  16. plugins.push(new UglifyJsPlugin({
  17. cache: true,
  18. extractComments: true,
  19. parallel: true,
  20. sourceMap: true
  21. }));
  22. }
  23. const config = {
  24. devtool: 'source-map',
  25. module: {
  26. rules: [ {
  27. // Version this build of the lib-jitsi-meet library.
  28. loader: 'string-replace-loader',
  29. options: {
  30. flags: 'g',
  31. replace:
  32. process.env.LIB_JITSI_MEET_COMMIT_HASH || 'development',
  33. search: '{#COMMIT_HASH#}'
  34. },
  35. test: `${__dirname}/JitsiMeetJS.js`
  36. }, {
  37. // Transpile ES2015 (aka ES6) to ES5.
  38. exclude: [
  39. `${__dirname}/modules/RTC/adapter.screenshare.js`,
  40. new RegExp(`${__dirname}/node_modules/(?!js-utils)`)
  41. ],
  42. loader: 'babel-loader',
  43. options: {
  44. presets: [
  45. [
  46. 'env',
  47. // Tell babel to avoid compiling imports into CommonJS
  48. // so that webpack may do tree shaking.
  49. { modules: false }
  50. ],
  51. 'stage-1'
  52. ]
  53. },
  54. test: /\.js$/
  55. } ]
  56. },
  57. node: {
  58. // Allow the use of the real filename of the module being executed. By
  59. // default Webpack does not leak path-related information and provides a
  60. // value that is a mock (/index.js).
  61. __filename: true
  62. },
  63. output: {
  64. filename: `[name]${minimize ? '.min' : ''}.js`,
  65. sourceMapFilename: `[name].${minimize ? 'min' : 'js'}.map`
  66. },
  67. plugins
  68. };
  69. module.exports = [
  70. Object.assign({}, config, {
  71. entry: {
  72. 'lib-jitsi-meet': './index.js'
  73. },
  74. output: Object.assign({}, config.output, {
  75. library: 'JitsiMeetJS',
  76. libraryTarget: 'umd'
  77. })
  78. })
  79. ];