webpack.common.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. url: false,
  59. sourceMap: true
  60. }
  61. },
  62. {
  63. loader: "postcss-loader",
  64. options: { sourceMap: true }
  65. },
  66. {
  67. loader: 'sass-loader',
  68. options: {
  69. sassOptions: {
  70. includePaths: [
  71. path.resolve(__dirname, '../node_modules/'),
  72. path.resolve(__dirname, '../src/')
  73. ]
  74. },
  75. sourceMap: true
  76. }
  77. },
  78. ]
  79. }, {
  80. test: /\.js$/,
  81. include: [
  82. /src/,
  83. /node_modules\/mergebounce/,
  84. /node_modules\/lit-html/,
  85. /node_modules\/strophe/,
  86. /node_modules\/pluggable/,
  87. /node_modules\/@converse/,
  88. ],
  89. use: {
  90. loader: 'babel-loader'
  91. }
  92. }, {
  93. test: /bootstrap\.native/,
  94. use: {
  95. loader: 'bootstrap.native-loader',
  96. options: {
  97. bs_version: 4,
  98. ignore: bootstrap_ignore_modules
  99. }
  100. }
  101. }],
  102. },
  103. resolve: {
  104. extensions: ['.js'],
  105. modules: [
  106. 'node_modules',
  107. path.resolve(__dirname, "../src")
  108. ],
  109. alias: {
  110. "IPv6": path.resolve(__dirname, "../node_modules/urijs/src/IPv6"),
  111. "SecondLevelDomains": path.resolve(__dirname, "../node_modules/urijs/src/SecondLevelDomains"),
  112. "punycode": path.resolve(__dirname, "../node_modules/urijs/src/punycode"),
  113. "./shims": path.resolve(__dirname, "../src/strophe-shims.js"),
  114. }
  115. }
  116. }