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 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /* global __dirname */
  2. require('babel-polyfill'); // Define Object.assign() from ES6 in ES5.
  3. var HasteResolverPlugin = require('haste-resolver-webpack-plugin');
  4. var process = require('process');
  5. var webpack = require('webpack');
  6. var aui_css = __dirname + '/node_modules/@atlassian/aui/dist/aui/css/';
  7. var minimize
  8. = process.argv.indexOf('-p') !== -1
  9. || process.argv.indexOf('--optimize-minimize') !== -1;
  10. var node_modules = __dirname + '/node_modules/';
  11. var plugins = [
  12. new HasteResolverPlugin()
  13. ];
  14. var strophe = /\/node_modules\/strophe(js-plugins)?\/.*\.js$/;
  15. if (minimize) {
  16. // XXX Webpack's command line argument -p is not enough. Further
  17. // optimizations are made possible by the use of DefinePlugin and NODE_ENV
  18. // with value 'production'. For example, React takes advantage of these.
  19. plugins.push(new webpack.DefinePlugin({
  20. 'process.env': {
  21. NODE_ENV: JSON.stringify('production')
  22. }
  23. }));
  24. }
  25. // The base Webpack configuration to bundle the JavaScript artifacts of
  26. // jitsi-meet such as app.bundle.js and external_api.js.
  27. var config = {
  28. devtool: 'source-map',
  29. module: {
  30. loaders: [ {
  31. // Transpile ES2015 (aka ES6) to ES5. Accept the JSX syntax by React
  32. // as well.
  33. exclude: node_modules,
  34. loader: 'babel',
  35. query: {
  36. // XXX The require.resolve bellow solves failures to locate the
  37. // presets when lib-jitsi-meet, for example, is npm linked in
  38. // jitsi-meet. The require.resolve, of course, mandates the use
  39. // of the prefix babel-preset- in the preset names.
  40. presets: [
  41. 'babel-preset-es2015',
  42. 'babel-preset-react',
  43. 'babel-preset-stage-1'
  44. ].map(require.resolve)
  45. },
  46. test: /\.jsx?$/
  47. }, {
  48. // Expose jquery as the globals $ and jQuery because it is expected
  49. // to be available in such a form by multiple jitsi-meet
  50. // dependencies including AUI, lib-jitsi-meet.
  51. loader: 'expose?$!expose?jQuery',
  52. test: /\/node_modules\/jquery\/.*\.js$/
  53. }, {
  54. // Disable AMD for the Strophe.js library or its imports will fail
  55. // at runtime.
  56. loader: 'imports?define=>false&this=>window',
  57. test: strophe
  58. }, {
  59. // Allow CSS to be imported into JavaScript.
  60. loaders: [
  61. 'style',
  62. 'css'
  63. ],
  64. test: /\.css$/
  65. }, {
  66. // Emit the static assets of AUI such as images that are referenced
  67. // by CSS into the output path.
  68. include: aui_css,
  69. loader: 'file',
  70. query: {
  71. context: aui_css,
  72. name: '[path][name].[ext]'
  73. },
  74. test: /\.(gif|png|svg)$/
  75. }, {
  76. // Enable the import of JSON files.
  77. loader: 'json',
  78. exclude: node_modules,
  79. test: /\.json$/
  80. } ],
  81. noParse: [
  82. // Do not parse the files of the Strophe.js library or at least
  83. // parts of the properties of the Strophe global variable will be
  84. // missing and strophejs-plugins will fail at runtime.
  85. strophe
  86. ]
  87. },
  88. node: {
  89. // Allow the use of the real filename of the module being executed. By
  90. // default Webpack does not leak path-related information and provides a
  91. // value that is a mock (/index.js).
  92. __filename: true
  93. },
  94. output: {
  95. filename: '[name]' + (minimize ? '.min' : '') + '.js',
  96. libraryTarget: 'umd',
  97. path: __dirname + '/build',
  98. sourceMapFilename: '[name].' + (minimize ? 'min' : 'js') + '.map'
  99. },
  100. plugins: plugins,
  101. resolve: {
  102. alias: {
  103. aui:
  104. '@atlassian/aui/dist/aui/js/aui'
  105. + (minimize ? '.min' : '')
  106. + '.js',
  107. 'aui-experimental':
  108. '@atlassian/aui/dist/aui/js/aui-experimental'
  109. + (minimize ? '.min' : '')
  110. + '.js',
  111. jquery: 'jquery/dist/jquery' + (minimize ? '.min' : '') + '.js',
  112. 'jQuery-Impromptu':
  113. 'jQuery-Impromptu/dist/jquery-impromptu'
  114. + (minimize ? '.min' : '')
  115. + '.js'
  116. },
  117. packageAlias: 'browser'
  118. }
  119. };
  120. module.exports = [
  121. // The Webpack configuration to bundle app.bundle.js (aka APP).
  122. Object.assign({}, config, {
  123. entry: {
  124. 'app.bundle': './app.js'
  125. },
  126. output: Object.assign({}, config.output, {
  127. library: 'APP'
  128. })
  129. }),
  130. // The Webpack configuration to bundle external_api.js (aka
  131. // JitsiMeetExternalAPI).
  132. Object.assign({}, config, {
  133. entry: {
  134. 'external_api': './modules/API/external/external_api.js'
  135. },
  136. output: Object.assign({}, config.output, {
  137. library: 'JitsiMeetExternalAPI'
  138. })
  139. })
  140. ];