Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

webpack.config.js 7.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. /* global __dirname */
  2. const process = require('process');
  3. const webpack = require('webpack');
  4. const aui_css = `${__dirname}/node_modules/@atlassian/aui/dist/aui/css/`;
  5. /**
  6. * The URL of the Jitsi Meet deployment to be proxy to in the context of
  7. * development with webpack-dev-server.
  8. */
  9. const devServerProxyTarget
  10. = process.env.WEBPACK_DEV_SERVER_PROXY_TARGET || 'https://beta.meet.jit.si';
  11. const minimize
  12. = process.argv.indexOf('-p') !== -1
  13. || process.argv.indexOf('--optimize-minimize') !== -1;
  14. const node_modules = `${__dirname}/node_modules/`;
  15. const plugins = [
  16. new webpack.LoaderOptionsPlugin({
  17. debug: !minimize,
  18. minimize
  19. })
  20. ];
  21. const strophe = /\/node_modules\/strophe(js-plugins)?\/.*\.js$/;
  22. if (minimize) {
  23. // XXX Webpack's command line argument -p is not enough. Further
  24. // optimizations are made possible by the use of DefinePlugin and NODE_ENV
  25. // with value 'production'. For example, React takes advantage of these.
  26. plugins.push(new webpack.DefinePlugin({
  27. 'process.env': {
  28. NODE_ENV: JSON.stringify('production')
  29. }
  30. }));
  31. plugins.push(new webpack.optimize.ModuleConcatenationPlugin());
  32. plugins.push(new webpack.optimize.UglifyJsPlugin({
  33. compress: {
  34. warnings: true
  35. },
  36. extractComments: true,
  37. sourceMap: true
  38. }));
  39. }
  40. // The base Webpack configuration to bundle the JavaScript artifacts of
  41. // jitsi-meet such as app.bundle.js and external_api.js.
  42. const config = {
  43. devServer: {
  44. https: true,
  45. inline: true,
  46. proxy: {
  47. '/': {
  48. bypass: devServerProxyBypass,
  49. secure: false,
  50. target: devServerProxyTarget
  51. }
  52. }
  53. },
  54. devtool: 'source-map',
  55. module: {
  56. rules: [ {
  57. // Transpile ES2015 (aka ES6) to ES5. Accept the JSX syntax by React
  58. // as well.
  59. exclude: node_modules,
  60. loader: 'babel-loader',
  61. options: {
  62. // XXX The require.resolve bellow solves failures to locate the
  63. // presets when lib-jitsi-meet, for example, is npm linked in
  64. // jitsi-meet. The require.resolve, of course, mandates the use
  65. // of the prefix babel-preset- in the preset names.
  66. presets: [
  67. [
  68. require.resolve('babel-preset-es2015'),
  69. // Tell babel to avoid compiling imports into CommonJS
  70. // so that webpack may do tree shaking.
  71. { modules: false }
  72. ],
  73. require.resolve('babel-preset-react'),
  74. require.resolve('babel-preset-stage-1')
  75. ]
  76. },
  77. test: /\.jsx?$/
  78. }, {
  79. // Expose jquery as the globals $ and jQuery because it is expected
  80. // to be available in such a form by multiple jitsi-meet
  81. // dependencies including AUI, lib-jitsi-meet.
  82. loader: 'expose-loader?$!expose-loader?jQuery',
  83. test: /\/node_modules\/jquery\/.*\.js$/
  84. }, {
  85. // Disable AMD for the Strophe.js library or its imports will fail
  86. // at runtime.
  87. loader: 'imports-loader?define=>false&this=>window',
  88. test: strophe
  89. }, {
  90. // Set scope to window for URL polyfill.
  91. loader: 'imports-loader?this=>window',
  92. test: /\/node_modules\/url-polyfill\/.*\.js$/
  93. }, {
  94. // Allow CSS to be imported into JavaScript.
  95. test: /\.css$/,
  96. use: [
  97. 'style-loader',
  98. 'css-loader'
  99. ]
  100. }, {
  101. // Emit the static assets of AUI such as images that are referenced
  102. // by CSS into the output path.
  103. include: aui_css,
  104. loader: 'file-loader',
  105. options: {
  106. context: aui_css,
  107. name: '[path][name].[ext]'
  108. },
  109. test: /\.(gif|png|svg)$/
  110. } ],
  111. noParse: [
  112. // Do not parse the files of the Strophe.js library or at least
  113. // parts of the properties of the Strophe global variable will be
  114. // missing and strophejs-plugins will fail at runtime.
  115. strophe
  116. ]
  117. },
  118. node: {
  119. // Allow the use of the real filename of the module being executed. By
  120. // default Webpack does not leak path-related information and provides a
  121. // value that is a mock (/index.js).
  122. __filename: true
  123. },
  124. output: {
  125. filename: `[name]${minimize ? '.min' : ''}.js`,
  126. path: `${__dirname}/build`,
  127. publicPath: '/libs/',
  128. sourceMapFilename: `[name].${minimize ? 'min' : 'js'}.map`
  129. },
  130. plugins,
  131. resolve: {
  132. alias: {
  133. jquery: `jquery/dist/jquery${minimize ? '.min' : ''}.js`
  134. },
  135. aliasFields: [
  136. 'browser'
  137. ],
  138. extensions: [
  139. '.web.js',
  140. // Webpack defaults:
  141. '.js',
  142. '.json'
  143. ]
  144. }
  145. };
  146. module.exports = [
  147. Object.assign({}, config, {
  148. entry: {
  149. 'app.bundle': [
  150. // XXX Required by at least IE11 at the time of this writing.
  151. 'babel-polyfill',
  152. './app.js'
  153. ],
  154. 'device_selection_popup_bundle':
  155. './react/features/device-selection/popup.js',
  156. 'alwaysontop':
  157. './react/features/always-on-top/index.js',
  158. 'do_external_connect':
  159. './connection_optimization/do_external_connect.js'
  160. }
  161. }),
  162. // The Webpack configuration to bundle external_api.js (aka
  163. // JitsiMeetExternalAPI).
  164. Object.assign({}, config, {
  165. entry: {
  166. 'external_api': './modules/API/external/index.js'
  167. },
  168. output: Object.assign({}, config.output, {
  169. library: 'JitsiMeetExternalAPI',
  170. libraryTarget: 'umd'
  171. })
  172. })
  173. ];
  174. /**
  175. * Determines whether a specific (HTTP) request is to bypass the proxy of
  176. * webpack-dev-server (i.e. is to be handled by the proxy target) and, if not,
  177. * which local file is to be served in response to the request.
  178. *
  179. * @param {Object} request - The (HTTP) request received by the proxy.
  180. * @returns {string|undefined} If the request is to be served by the proxy
  181. * target, undefined; otherwise, the path to the local file to be served.
  182. */
  183. function devServerProxyBypass({ path }) {
  184. if (path.startsWith('/css/') || path.startsWith('/doc/')) {
  185. return path;
  186. }
  187. const configs = module.exports;
  188. if ((Array.isArray(configs) ? configs : Array(configs)).some(c => {
  189. if (path.startsWith(c.output.publicPath)) {
  190. if (!minimize) {
  191. // Since webpack-dev-server is serving non-minimized
  192. // artifacts, serve them even if the minimized ones are
  193. // requested.
  194. Object.keys(c.entry).some(e => {
  195. const name = `${e}.min.js`;
  196. if (path.indexOf(name) !== -1) {
  197. path = path.replace(name, `${e}.js`);
  198. return true;
  199. }
  200. });
  201. }
  202. return true;
  203. }
  204. })) {
  205. return path;
  206. }
  207. }