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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. { modules: false }
  35. ],
  36. '@babel/preset-flow'
  37. ],
  38. plugins: [
  39. '@babel/plugin-transform-flow-strip-types',
  40. '@babel/plugin-proposal-class-properties',
  41. '@babel/plugin-proposal-export-namespace-from'
  42. ]
  43. },
  44. test: /\.js$/
  45. } ]
  46. },
  47. node: {
  48. // Allow the use of the real filename of the module being executed. By
  49. // default Webpack does not leak path-related information and provides a
  50. // value that is a mock (/index.js).
  51. __filename: true
  52. },
  53. optimization: {
  54. concatenateModules: minimize
  55. },
  56. output: {
  57. filename: `[name]${minimize ? '.min' : ''}.js`,
  58. path: process.cwd(),
  59. sourceMapFilename: `[name].${minimize ? 'min' : 'js'}.map`
  60. },
  61. performance: {
  62. maxAssetSize: 750000,
  63. maxEntrypointSize: 750000
  64. },
  65. plugins: [
  66. analyzeBundle
  67. && new BundleAnalyzerPlugin({
  68. analyzerMode: 'disabled',
  69. generateStatsFile: true
  70. })
  71. ].filter(Boolean)
  72. };
  73. module.exports = [
  74. Object.assign({}, config, {
  75. entry: {
  76. 'lib-jitsi-meet': './index.js'
  77. },
  78. output: Object.assign({}, config.output, {
  79. library: 'JitsiMeetJS',
  80. libraryTarget: 'umd'
  81. })
  82. })
  83. ];