webpack.renderer.config.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2017-2020 @polkadot/apps authors & contributors
  2. // This software may be modified and distributed under the terms
  3. // of the Apache-2.0 license. See the LICENSE file for details.
  4. /* eslint-disable @typescript-eslint/camelcase */
  5. const merge = require('webpack-merge');
  6. const baseConfig = require('@polkadot/apps/webpack.base.config');
  7. const path = require('path');
  8. const CopyWebpackPlugin = require('copy-webpack-plugin');
  9. const HtmlWebpackPlugin = require('html-webpack-plugin');
  10. const findPackages = require('../../scripts/findPackages');
  11. const ENV = process.env.NODE_ENV || 'development';
  12. const isProd = ENV === 'production';
  13. const context = __dirname;
  14. module.exports = merge(
  15. baseConfig({
  16. alias: findPackages().reduce((alias, { dir, name }) => {
  17. alias[name] = path.resolve(context, `../${dir}/src`);
  18. return alias;
  19. }, {}),
  20. context
  21. }),
  22. {
  23. devServer: {
  24. compress: true,
  25. contentBase: path.join(__dirname, 'build'),
  26. hot: true,
  27. liveReload: false,
  28. port: 9000
  29. },
  30. devtool: isProd ? 'none' : 'source-map',
  31. plugins: [
  32. new CopyWebpackPlugin([{ from: '../apps/public' }]),
  33. new HtmlWebpackPlugin({
  34. PAGE_TITLE: 'Polkadot/Substrate Portal',
  35. inject: true,
  36. template: path.join(context, '../apps/public/index.html')
  37. })
  38. ],
  39. target: 'electron-renderer'
  40. }
  41. );