webpack.prod.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* global __dirname, module, process */
  2. const ASSET_PATH = process.env.ASSET_PATH || '/dist/'; // eslint-disable-line no-process-env
  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 webpack = require('webpack');
  8. const { CleanWebpackPlugin } = require('clean-webpack-plugin');
  9. const { merge} = require("webpack-merge");
  10. module.exports = merge(common, {
  11. output: {
  12. publicPath: ASSET_PATH,
  13. filename: 'converse.min.js',
  14. },
  15. plugins: [
  16. new CleanWebpackPlugin({
  17. cleanStaleWebpackAssets: false // resolves conflict with CopyWebpackPlugin
  18. }),
  19. new MiniCssExtractPlugin({filename: '../dist/converse.min.css'}),
  20. new CopyWebpackPlugin({
  21. patterns: [
  22. {from: 'src/headless/node_modules/strophe.js/src/shared-connection-worker.js', to: 'shared-connection-worker.js'},
  23. {from: 'sounds', to: 'sounds'},
  24. {from: 'images/favicon.ico', to: 'images/favicon.ico'},
  25. {from: 'images/custom_emojis', to: 'images/custom_emojis'},
  26. {from: 'logo/conversejs-filled-192.png', to: 'images/logo'},
  27. {from: 'logo/conversejs-filled-512.png', to: 'images/logo'},
  28. {from: 'logo/conversejs-filled-192.svg', to: 'images/logo'},
  29. {from: 'logo/conversejs-filled-512.svg', to: 'images/logo'},
  30. {from: 'sass/webfonts', to: 'webfonts'}
  31. ]
  32. }),
  33. new webpack.DefinePlugin({ // This makes it possible for us to safely use env vars on our code
  34. 'process.env.ASSET_PATH': JSON.stringify(ASSET_PATH)
  35. })
  36. ],
  37. mode: "production",
  38. devtool: "source-map",
  39. module: {
  40. rules: [{
  41. test: /\.scss$/,
  42. use: [
  43. MiniCssExtractPlugin.loader,
  44. {
  45. loader: 'css-loader',
  46. options: {
  47. url: false,
  48. sourceMap: true
  49. }
  50. },
  51. 'postcss-loader',
  52. {
  53. loader: 'sass-loader',
  54. options: {
  55. sassOptions: {
  56. includePaths: [path.resolve(__dirname, 'node_modules/')]
  57. },
  58. sourceMap: true
  59. }
  60. }
  61. ]
  62. }]
  63. }
  64. });