webpack.build.js 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* global __dirname, module, process */
  2. const ASSET_PATH = process.env.ASSET_PATH || '/dist/'; // eslint-disable-line no-process-env
  3. const CircularDependencyPlugin = require('circular-dependency-plugin');
  4. const CopyWebpackPlugin = require('copy-webpack-plugin');
  5. const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  6. const common = require("./webpack.common.js");
  7. const path = require('path');
  8. const webpack = require('webpack');
  9. const { merge } = require("webpack-merge");
  10. const plugins = [
  11. new MiniCssExtractPlugin({filename: '../dist/converse.min.css'}),
  12. new MiniCssExtractPlugin({filename: '../dist/converse.css'}),
  13. new CopyWebpackPlugin({
  14. patterns: [
  15. {from: 'node_modules/strophe.js/src/shared-connection-worker.js', to: 'shared-connection-worker.js'},
  16. {from: 'sounds', to: 'sounds'},
  17. {from: 'images/favicon.ico', to: 'images/favicon.ico'},
  18. {from: 'images/custom_emojis', to: 'images/custom_emojis'},
  19. {from: 'logo/conversejs-filled-192.png', to: 'images/logo'},
  20. {from: 'logo/conversejs-filled-512.png', to: 'images/logo'},
  21. {from: 'logo/conversejs-filled-192.svg', to: 'images/logo'},
  22. {from: 'logo/conversejs-filled-512.svg', to: 'images/logo'},
  23. {from: 'logo/conversejs-filled.svg', to: 'images/logo'},
  24. {from: 'logo/conversejs-gold-gradient.svg', to: 'images/logo'},
  25. {from: 'src/shared/styles/webfonts', to: 'webfonts'}
  26. ]
  27. }),
  28. new webpack.DefinePlugin({ // This makes it possible for us to safely use env vars on our code
  29. 'process.env.ASSET_PATH': JSON.stringify(ASSET_PATH)
  30. }),
  31. new CircularDependencyPlugin({
  32. exclude: /node_modules/,
  33. failOnError: false,
  34. allowAsyncCycles: false,
  35. cwd: process.cwd(),
  36. })
  37. ];
  38. module.exports = merge(common, {
  39. plugins,
  40. entry: {
  41. "converse": path.resolve(__dirname, "../src/entry.js"),
  42. "converse.min": path.resolve(__dirname, "../src/entry.js"),
  43. },
  44. output: {
  45. publicPath: ASSET_PATH,
  46. filename: "[name].js",
  47. },
  48. mode: "production",
  49. module: {
  50. rules: [{
  51. test: /\.scss$/,
  52. use: [
  53. MiniCssExtractPlugin.loader,
  54. {
  55. loader: 'css-loader',
  56. options: {
  57. url: false,
  58. sourceMap: true
  59. }
  60. },
  61. {
  62. loader: "postcss-loader",
  63. options: { sourceMap: true }
  64. },
  65. {
  66. loader: 'sass-loader',
  67. options: {
  68. sassOptions: {
  69. includePaths: [
  70. path.resolve(__dirname, '../node_modules/'),
  71. path.resolve(__dirname, '../src/')
  72. ]
  73. },
  74. sourceMap: true
  75. }
  76. },
  77. ]
  78. }]
  79. }
  80. });