webpack.common.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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: /src/,
  75. use: {
  76. loader: 'babel-loader',
  77. options: {
  78. presets: [
  79. ["@babel/preset-env", {
  80. "targets": {
  81. "browsers": [">1%", "not ie 11", "not op_mini all", "not dead"]
  82. }
  83. }]
  84. ],
  85. plugins: [
  86. 'lodash',
  87. '@babel/plugin-proposal-class-properties',
  88. '@babel/plugin-proposal-nullish-coalescing-operator',
  89. '@babel/plugin-proposal-optional-chaining',
  90. '@babel/plugin-syntax-dynamic-import'
  91. ]
  92. }
  93. }
  94. }, {
  95. test: /bootstrap\.native/,
  96. use: {
  97. loader: 'bootstrap.native-loader',
  98. options: {
  99. bs_version: 4,
  100. ignore: bootstrap_ignore_modules
  101. }
  102. }
  103. }],
  104. },
  105. resolve: {
  106. extensions: ['.js'],
  107. modules: [
  108. 'node_modules',
  109. path.resolve(__dirname, "src")
  110. ],
  111. alias: {
  112. "IPv6": path.resolve(__dirname, "node_modules/urijs/src/IPv6"),
  113. "SecondLevelDomains": path.resolve(__dirname, "node_modules/urijs/src/SecondLevelDomains"),
  114. "formdata-polyfill": path.resolve(__dirname, "node_modules/formdata-polyfill/FormData"),
  115. "punycode": path.resolve(__dirname, "node_modules/urijs/src/punycode")
  116. }
  117. }
  118. }