Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

webpack.config.js 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. 'stage-1'
  71. ]
  72. },
  73. test: /\.js$/
  74. } ]
  75. },
  76. node: {
  77. // Allow the use of the real filename of the module being executed. By
  78. // default Webpack does not leak path-related information and provides a
  79. // value that is a mock (/index.js).
  80. __filename: true
  81. },
  82. output: {
  83. filename: `[name]${minimize ? '.min' : ''}.js`,
  84. library: 'JitsiMeetJS',
  85. libraryTarget: 'umd',
  86. sourceMapFilename: `[name].${minimize ? 'min' : 'js'}.map`
  87. },
  88. plugins
  89. };