您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

webpack.config.js 2.8KB

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