webpack.common.js 4.0 KB

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