webpack.build.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* global __dirname, module, process */
  2. const CircularDependencyPlugin = require('circular-dependency-plugin');
  3. const CopyWebpackPlugin = require('copy-webpack-plugin');
  4. const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  5. const common = require("./webpack.common.js");
  6. const path = require('path');
  7. const { merge } = require("webpack-merge");
  8. const plugins = [
  9. new MiniCssExtractPlugin({filename: '../dist/converse.min.css'}),
  10. new MiniCssExtractPlugin({filename: '../dist/converse.css'}),
  11. new CopyWebpackPlugin({
  12. patterns: [
  13. {from: 'node_modules/strophe.js/src/shared-connection-worker.js', to: 'shared-connection-worker.js'},
  14. {from: 'sounds', to: 'sounds'},
  15. {from: 'images/favicon.ico', to: 'images/favicon.ico'},
  16. {from: 'images/custom_emojis', to: 'images/custom_emojis'},
  17. {from: 'logo/conversejs-filled-192.png', to: 'images/logo'},
  18. {from: 'logo/conversejs-filled-512.png', to: 'images/logo'},
  19. {from: 'logo/conversejs-filled-192.svg', to: 'images/logo'},
  20. {from: 'logo/conversejs-filled-512.svg', to: 'images/logo'},
  21. {from: 'logo/conversejs-filled.svg', to: 'images/logo'},
  22. {from: 'logo/conversejs-gold-gradient.svg', to: 'images/logo'},
  23. {from: 'src/shared/styles/webfonts', to: 'webfonts'},
  24. {from: 'manifest.json', to: 'manifest.json'}
  25. ]
  26. }),
  27. new CircularDependencyPlugin({
  28. exclude: /node_modules/,
  29. failOnError: true,
  30. allowAsyncCycles: false,
  31. cwd: process.cwd(),
  32. })
  33. ];
  34. module.exports = merge(common, {
  35. plugins,
  36. entry: {
  37. "converse": path.resolve(__dirname, "../src/entry.js"),
  38. "converse.min": path.resolve(__dirname, "../src/entry.js"),
  39. },
  40. output: {
  41. filename: "[name].js",
  42. },
  43. mode: "production",
  44. module: {
  45. rules: [{
  46. test: /\.(js|ts)$/,
  47. use: [{
  48. loader: 'minify-html-literals-loader'
  49. }]
  50. },
  51. {
  52. test: /\.scss$/,
  53. use: [
  54. MiniCssExtractPlugin.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. }
  81. });