webpack.config.js 1.0 KB

1234567891011121314151617181920212223242526272829303132
  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 camelcase */
  5. const fs = require('fs');
  6. const path = require('path');
  7. const merge = require('webpack-merge');
  8. const baseConfig = require('./webpack.base.config');
  9. const HtmlWebpackPlugin = require('html-webpack-plugin');
  10. const ENV = process.env.NODE_ENV || 'development';
  11. const IS_LIVE = !(process.env.IS_LIVE === false || process.env.IS_LIVE === 'false');
  12. const context = __dirname;
  13. const hasPublic = fs.existsSync(path.join(context, 'public'));
  14. module.exports = merge(
  15. baseConfig(ENV, context),
  16. {
  17. devtool: process.env.BUILD_ANALYZE ? 'source-map' : false,
  18. plugins: [
  19. new HtmlWebpackPlugin({
  20. IS_PROD: ENV === 'production',
  21. IS_LIVE,
  22. PAGE_TITLE: 'Joystream Network Portal',
  23. inject: true,
  24. template: path.join(context, `${hasPublic ? 'public/' : ''}index.html`)
  25. })
  26. ]
  27. }
  28. );