webpack.config.common.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // Copyright 2019 The go-ethereum Authors
  2. // This file is part of the go-ethereum library.
  3. //
  4. // The go-ethereum library is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Lesser General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // The go-ethereum library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Lesser General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Lesser General Public License
  15. // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
  16. const path = require('path');
  17. module.exports = {
  18. target: 'web',
  19. entry: {
  20. bundle: './index',
  21. },
  22. output: {
  23. filename: '[name].js',
  24. path: path.resolve(__dirname, ''),
  25. sourceMapFilename: '[file].map',
  26. },
  27. resolve: {
  28. modules: [
  29. 'node_modules',
  30. path.resolve(__dirname, 'components'), // import './components/Component' -> import 'Component'
  31. ],
  32. extensions: ['.js', '.jsx'],
  33. },
  34. module: {
  35. rules: [
  36. {
  37. test: /\.jsx$/, // regexp for JSX files
  38. exclude: /node_modules/,
  39. use: [ // order: from bottom to top
  40. {
  41. loader: 'babel-loader',
  42. options: {
  43. presets: [ // order: from bottom to top
  44. '@babel/env',
  45. '@babel/react',
  46. ],
  47. plugins: [ // order: from top to bottom
  48. '@babel/proposal-function-bind', // instead of stage 0
  49. '@babel/proposal-class-properties', // static defaultProps
  50. '@babel/transform-flow-strip-types',
  51. 'react-hot-loader/babel',
  52. ],
  53. },
  54. },
  55. // 'eslint-loader', // show errors in the console
  56. ],
  57. },
  58. {
  59. test: /\.css$/,
  60. oneOf: [
  61. {
  62. test: /font-awesome/,
  63. use: [
  64. 'style-loader',
  65. 'css-loader',
  66. path.resolve(__dirname, './fa-only-woff-loader.js'),
  67. ],
  68. },
  69. {
  70. use: [
  71. 'style-loader',
  72. 'css-loader',
  73. ],
  74. },
  75. ],
  76. },
  77. {
  78. test: /\.woff2?$/, // font-awesome icons
  79. use: 'url-loader',
  80. },
  81. ],
  82. },
  83. };