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

webpack.config.js 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. /* global __dirname */
  2. const process = require('process');
  3. /**
  4. * The URL of the Jitsi Meet deployment to be proxy to in the context of
  5. * development with webpack-dev-server.
  6. */
  7. const devServerProxyTarget
  8. = process.env.WEBPACK_DEV_SERVER_PROXY_TARGET || 'https://beta.meet.jit.si';
  9. const minimize
  10. = process.argv.indexOf('-p') !== -1
  11. || process.argv.indexOf('--optimize-minimize') !== -1;
  12. // The base Webpack configuration to bundle the JavaScript artifacts of
  13. // jitsi-meet such as app.bundle.js and external_api.js.
  14. const config = {
  15. devServer: {
  16. https: true,
  17. inline: true,
  18. proxy: {
  19. '/': {
  20. bypass: devServerProxyBypass,
  21. secure: false,
  22. target: devServerProxyTarget
  23. }
  24. }
  25. },
  26. devtool: 'source-map',
  27. mode: minimize ? 'production' : 'development',
  28. module: {
  29. rules: [ {
  30. // Transpile ES2015 (aka ES6) to ES5. Accept the JSX syntax by React
  31. // as well.
  32. exclude: [
  33. new RegExp(`${__dirname}/node_modules/(?!js-utils)`)
  34. ],
  35. loader: 'babel-loader',
  36. options: {
  37. // XXX The require.resolve bellow solves failures to locate the
  38. // presets when lib-jitsi-meet, for example, is npm linked in
  39. // jitsi-meet.
  40. plugins: [
  41. require.resolve('@babel/plugin-transform-flow-strip-types'),
  42. require.resolve('@babel/plugin-proposal-class-properties'),
  43. require.resolve(
  44. '@babel/plugin-proposal-export-default-from'),
  45. require.resolve(
  46. '@babel/plugin-proposal-export-namespace-from')
  47. ],
  48. presets: [
  49. [
  50. require.resolve('@babel/preset-env'),
  51. // Tell babel to avoid compiling imports into CommonJS
  52. // so that webpack may do tree shaking.
  53. { modules: false }
  54. ],
  55. require.resolve('@babel/preset-flow'),
  56. require.resolve('@babel/preset-react')
  57. ]
  58. },
  59. test: /\.jsx?$/
  60. }, {
  61. // Expose jquery as the globals $ and jQuery because it is expected
  62. // to be available in such a form by multiple jitsi-meet
  63. // dependencies including lib-jitsi-meet.
  64. loader: 'expose-loader?$!expose-loader?jQuery',
  65. test: /\/node_modules\/jquery\/.*\.js$/
  66. }, {
  67. // Allow CSS to be imported into JavaScript.
  68. test: /\.css$/,
  69. use: [
  70. 'style-loader',
  71. 'css-loader'
  72. ]
  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. optimization: {
  82. concatenateModules: minimize,
  83. minimize
  84. },
  85. output: {
  86. filename: `[name]${minimize ? '.min' : ''}.js`,
  87. path: `${__dirname}/build`,
  88. publicPath: '/libs/',
  89. sourceMapFilename: `[name].${minimize ? 'min' : 'js'}.map`
  90. },
  91. resolve: {
  92. alias: {
  93. jquery: `jquery/dist/jquery${minimize ? '.min' : ''}.js`
  94. },
  95. aliasFields: [
  96. 'browser'
  97. ],
  98. extensions: [
  99. '.web.js',
  100. // Webpack defaults:
  101. '.js',
  102. '.json'
  103. ]
  104. }
  105. };
  106. module.exports = [
  107. Object.assign({}, config, {
  108. entry: {
  109. 'app.bundle': './app.js',
  110. 'device_selection_popup_bundle':
  111. './react/features/settings/popup.js',
  112. 'alwaysontop':
  113. './react/features/always-on-top/index.js',
  114. 'dial_in_info_bundle': [
  115. './react/features/invite/components/dial-in-info-page'
  116. ],
  117. 'do_external_connect':
  118. './connection_optimization/do_external_connect.js',
  119. 'flacEncodeWorker':
  120. './react/features/local-recording/'
  121. + 'recording/flac/flacEncodeWorker.js',
  122. 'analytics-ga':
  123. './react/features/analytics/handlers/GoogleAnalyticsHandler.js'
  124. }
  125. }),
  126. // The Webpack configuration to bundle external_api.js (aka
  127. // JitsiMeetExternalAPI).
  128. Object.assign({}, config, {
  129. entry: {
  130. 'external_api': './modules/API/external/index.js'
  131. },
  132. output: Object.assign({}, config.output, {
  133. library: 'JitsiMeetExternalAPI',
  134. libraryTarget: 'umd'
  135. })
  136. })
  137. ];
  138. /**
  139. * Determines whether a specific (HTTP) request is to bypass the proxy of
  140. * webpack-dev-server (i.e. is to be handled by the proxy target) and, if not,
  141. * which local file is to be served in response to the request.
  142. *
  143. * @param {Object} request - The (HTTP) request received by the proxy.
  144. * @returns {string|undefined} If the request is to be served by the proxy
  145. * target, undefined; otherwise, the path to the local file to be served.
  146. */
  147. function devServerProxyBypass({ path }) {
  148. if (path.startsWith('/css/') || path.startsWith('/doc/')
  149. || path.startsWith('/fonts/')) {
  150. return path;
  151. }
  152. const configs = module.exports;
  153. /* eslint-disable array-callback-return, indent */
  154. if ((Array.isArray(configs) ? configs : Array(configs)).some(c => {
  155. if (path.startsWith(c.output.publicPath)) {
  156. if (!minimize) {
  157. // Since webpack-dev-server is serving non-minimized
  158. // artifacts, serve them even if the minimized ones are
  159. // requested.
  160. Object.keys(c.entry).some(e => {
  161. const name = `${e}.min.js`;
  162. if (path.indexOf(name) !== -1) {
  163. // eslint-disable-next-line no-param-reassign
  164. path = path.replace(name, `${e}.js`);
  165. return true;
  166. }
  167. });
  168. }
  169. return true;
  170. }
  171. })) {
  172. return path;
  173. }
  174. /* eslint-enable array-callback-return, indent */
  175. }