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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* global __dirname */
  2. const child_process = require('child_process'); // eslint-disable-line camelcase
  3. const process = require('process');
  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. // While webpack will automatically insert UglifyJsPlugin when minimize is
  16. // true, the defaults of UglifyJsPlugin in webpack 1 and webpack 2 are
  17. // different. Explicitly state what we want even if we want defaults in
  18. // order to prepare for webpack 2.
  19. plugins.push(new webpack.optimize.UglifyJsPlugin({
  20. compress: {
  21. // It is nice to see warnings from UglifyJsPlugin that something is
  22. // unused and, consequently, is removed. The default is false in
  23. // webpack 2.
  24. warnings: true
  25. },
  26. extractComments: true,
  27. // Use the source map to map error message locations to modules. The
  28. // default is false in webpack 2.
  29. sourceMap: true
  30. }));
  31. }
  32. module.exports = {
  33. devtool: 'source-map',
  34. entry: {
  35. 'lib-jitsi-meet': './index.js'
  36. },
  37. module: {
  38. rules: [ {
  39. // Version this build of the lib-jitsi-meet library.
  40. loader: 'string-replace-loader',
  41. options: {
  42. flags: 'g',
  43. replace:
  44. child_process.execSync( // eslint-disable-line camelcase
  45. `${__dirname}/get-version.sh`)
  46. // The type of the return value of
  47. // child_process.execSync is either Buffer or String.
  48. .toString()
  49. // Shells may automatically append CR and/or LF
  50. // characters to the output.
  51. .trim(),
  52. search: '{#COMMIT_HASH#}'
  53. },
  54. test: `${__dirname}/JitsiMeetJS.js`
  55. }, {
  56. // Transpile ES2015 (aka ES6) to ES5.
  57. exclude: [
  58. `${__dirname}/modules/RTC/adapter.screenshare.js`,
  59. `${__dirname}/node_modules/`
  60. ],
  61. loader: 'babel-loader',
  62. options: {
  63. presets: [
  64. [
  65. 'es2015',
  66. // Tell babel to avoid compiling imports into CommonJS
  67. // so that webpack may do tree shaking.
  68. { modules: false }
  69. ]
  70. ]
  71. },
  72. test: /\.js$/
  73. } ]
  74. },
  75. node: {
  76. // Allow the use of the real filename of the module being executed. By
  77. // default Webpack does not leak path-related information and provides a
  78. // value that is a mock (/index.js).
  79. __filename: true
  80. },
  81. output: {
  82. filename: `[name]${minimize ? '.min' : ''}.js`,
  83. library: 'JitsiMeetJS',
  84. libraryTarget: 'umd',
  85. sourceMapFilename: `[name].${minimize ? 'min' : 'js'}.map`
  86. },
  87. plugins
  88. };