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

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