webpack.build.js 2.6 KB

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