webpack.prod.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 { merge} = require("webpack-merge");
  9. const plugins = [
  10. new MiniCssExtractPlugin({filename: '../dist/converse.min.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: 'sass/webfonts', to: 'webfonts'}
  22. ]
  23. }),
  24. new webpack.DefinePlugin({ // This makes it possible for us to safely use env vars on our code
  25. 'process.env.ASSET_PATH': JSON.stringify(ASSET_PATH)
  26. })
  27. ];
  28. module.exports = merge(common, {
  29. plugins,
  30. output: {
  31. publicPath: ASSET_PATH,
  32. filename: 'converse.min.js',
  33. },
  34. mode: "production",
  35. devtool: "source-map",
  36. module: {
  37. rules: [{
  38. test: /\.scss$/,
  39. use: [
  40. MiniCssExtractPlugin.loader,
  41. {
  42. loader: 'css-loader',
  43. options: {
  44. url: false,
  45. sourceMap: true
  46. }
  47. },
  48. 'postcss-loader',
  49. {
  50. loader: 'sass-loader',
  51. options: {
  52. sassOptions: {
  53. includePaths: [path.resolve(__dirname, 'node_modules/')]
  54. },
  55. sourceMap: true
  56. }
  57. }
  58. ]
  59. }]
  60. }
  61. });