webpack.common.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* global __dirname, module, process */
  2. const TerserPlugin = require("terser-webpack-plugin");
  3. const path = require('path');
  4. let bootstrap_ignore_modules = ['carousel', 'scrollspy', 'tooltip', 'toast'];
  5. const BOOTSTRAP_IGNORE_MODULES = (process.env.BOOTSTRAP_IGNORE_MODULES || '').replace(/ /g, '').trim();
  6. if (BOOTSTRAP_IGNORE_MODULES.length > 0) {
  7. bootstrap_ignore_modules = bootstrap_ignore_modules.concat(BOOTSTRAP_IGNORE_MODULES.split(','));
  8. }
  9. module.exports = {
  10. output: {
  11. path: path.resolve(__dirname, '../dist'), // Output path for generated bundles
  12. chunkFilename: '[name].js'
  13. },
  14. devtool: "source-map",
  15. optimization: {
  16. minimize: true,
  17. minimizer: [
  18. new TerserPlugin({
  19. include: /\.min\.js$/
  20. })
  21. ],
  22. },
  23. externals: [{
  24. "window": "window"
  25. }],
  26. watchOptions: {
  27. ignored: /dist/,
  28. },
  29. module: {
  30. rules: [
  31. {
  32. test: /LC_MESSAGES[\\/]converse.po$/,
  33. type: "json",
  34. use: [
  35. {
  36. loader: 'po-loader',
  37. options: {
  38. 'format': 'jed',
  39. 'domain': 'converse'
  40. }
  41. }
  42. ]
  43. }, {
  44. test: /webfonts[\\/].*\.(woff(2)?|ttf|eot|truetype|svg)(\?v=\d+\.\d+\.\d+)?$/,
  45. type: 'asset/resource',
  46. generator: {
  47. filename: '[name][ext]',
  48. publicPath: 'webfonts/',
  49. outputPath: 'webfonts/'
  50. }
  51. }, {
  52. test: /\.scss$/,
  53. use: [
  54. 'style-loader',
  55. {
  56. loader: 'css-loader',
  57. options: {
  58. sourceMap: true
  59. }
  60. },
  61. 'postcss-loader',
  62. {
  63. loader: 'sass-loader',
  64. options: {
  65. sassOptions: {
  66. includePaths: [
  67. path.resolve(__dirname, '../node_modules/'),
  68. path.resolve(__dirname, '../src/')
  69. ]
  70. },
  71. sourceMap: true
  72. }
  73. }
  74. ]
  75. }, {
  76. test: /\.js$/,
  77. include: [
  78. /src/,
  79. /node_modules\/mergebounce/,
  80. /node_modules\/lit-html/,
  81. /node_modules\/strophe/,
  82. /node_modules\/pluggable/,
  83. /node_modules\/@converse/,
  84. ],
  85. use: {
  86. loader: 'babel-loader',
  87. options: {
  88. presets: [
  89. ["@babel/preset-env", {
  90. "targets": {
  91. "browsers": [">1%", "not ie 11", "not op_mini all", "not dead"]
  92. }
  93. }]
  94. ],
  95. plugins: []
  96. }
  97. }
  98. }, {
  99. test: /bootstrap\.native/,
  100. use: {
  101. loader: 'bootstrap.native-loader',
  102. options: {
  103. bs_version: 4,
  104. ignore: bootstrap_ignore_modules
  105. }
  106. }
  107. }],
  108. },
  109. resolve: {
  110. extensions: ['.js'],
  111. modules: [
  112. 'node_modules',
  113. path.resolve(__dirname, "../src")
  114. ],
  115. alias: {
  116. "IPv6": path.resolve(__dirname, "../node_modules/urijs/src/IPv6"),
  117. "SecondLevelDomains": path.resolve(__dirname, "../node_modules/urijs/src/SecondLevelDomains"),
  118. "formdata-polyfill": path.resolve(__dirname, "../node_modules/formdata-polyfill/FormData"),
  119. "punycode": path.resolve(__dirname, "../node_modules/urijs/src/punycode"),
  120. "./shims": path.resolve(__dirname, "../src/strophe-shims.js"),
  121. }
  122. }
  123. }