2
0

webpack.common.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /* global __dirname, module */
  2. const path = require('path');
  3. bootstrap_ignore_modules = ['carousel', 'scrollspy'];
  4. 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. module.exports = {
  8. output: {
  9. path: path.resolve(__dirname, 'dist'), // Output path for generated bundles
  10. chunkFilename: '[name].js'
  11. },
  12. entry: path.resolve(__dirname, 'src/entry.js'),
  13. externals: [{
  14. "window": "window"
  15. }],
  16. watchOptions: {
  17. ignored: [/dist/, /spec/, /.*\~/]
  18. },
  19. module: {
  20. rules: [
  21. {
  22. test: path.resolve(__dirname, "node_modules/xss/dist/xss"),
  23. use: "exports-loader?filterXSS,filterCSS"
  24. },
  25. {
  26. test: /\.(html|svg)$/,
  27. exclude: /node_modules/,
  28. use: [{
  29. loader: 'lodash-template-webpack-loader',
  30. options: {
  31. "escape": /\{\{\{([\s\S]+?)\}\}\}/g,
  32. "evaluate": /\{\[([\s\S]+?)\]\}/g,
  33. "interpolate": /\{\{([\s\S]+?)\}\}/g,
  34. // By default, template places the values from your data in the
  35. // local scope via the with statement. However, you can specify
  36. // a single variable name with the variable setting. This can
  37. // significantly improve the speed at which a template is able
  38. // to render.
  39. "variable": 'o',
  40. "prependFilenameComment": __dirname
  41. }
  42. }]
  43. }, {
  44. test: /LC_MESSAGES\/converse.po$/,
  45. type: "json",
  46. use: [
  47. {
  48. loader: 'po-loader',
  49. options: {
  50. 'format': 'jed',
  51. 'domain': 'converse'
  52. }
  53. }
  54. ]
  55. }, {
  56. test: /webfonts\/.*\.(woff(2)?|ttf|eot|truetype|svg)(\?v=\d+\.\d+\.\d+)?$/,
  57. use: [
  58. {
  59. loader: 'file-loader',
  60. options: {
  61. name: '[name].[ext]',
  62. outputPath: 'webfonts/'
  63. }
  64. }
  65. ]
  66. }, {
  67. test: /\.scss$/,
  68. use: [
  69. 'style-loader',
  70. {
  71. loader: 'css-loader',
  72. options: {
  73. sourceMap: true
  74. }
  75. },
  76. 'postcss-loader',
  77. {
  78. loader: 'sass-loader',
  79. options: {
  80. includePaths: [
  81. path.resolve(__dirname, 'node_modules/'),
  82. ],
  83. sourceMap: true
  84. }
  85. }
  86. ]
  87. }, {
  88. test: /\.js$/,
  89. exclude: /(node_modules|spec|mockup)/,
  90. use: {
  91. loader: 'babel-loader',
  92. options: {
  93. presets: [
  94. ["@babel/preset-env", {
  95. "targets": {
  96. "browsers": [">1%", "not ie 11", "not op_mini all"]
  97. }
  98. }]
  99. ],
  100. plugins: ['@babel/plugin-syntax-dynamic-import']
  101. }
  102. }
  103. }, {
  104. test: /bootstrap\.native/,
  105. use: {
  106. loader: 'bootstrap.native-loader',
  107. options: {
  108. bs_version: 4,
  109. ignore: bootstrap_ignore_modules
  110. }
  111. }
  112. }],
  113. },
  114. resolve: {
  115. extensions: ['.js'],
  116. modules: [
  117. 'node_modules',
  118. path.resolve(__dirname, "src")
  119. ],
  120. alias: {
  121. "IPv6": path.resolve(__dirname, "node_modules/urijs/src/IPv6"),
  122. "SecondLevelDomains": path.resolve(__dirname, "node_modules/urijs/src/SecondLevelDomains"),
  123. "formdata-polyfill": path.resolve(__dirname, "node_modules/formdata-polyfill/FormData"),
  124. "punycode": path.resolve(__dirname, "node_modules/urijs/src/punycode")
  125. }
  126. }
  127. }