github.com/googgoog/go-ethereum@v1.9.7/dashboard/assets/webpack.config.common.js (about)

     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  
    17  const path = require('path');
    18  
    19  module.exports = {
    20  	target: 'web',
    21  	entry:  {
    22  		bundle: './index',
    23  	},
    24  	output: {
    25  		filename:          '[name].js',
    26  		path:              path.resolve(__dirname, ''),
    27  		sourceMapFilename: '[file].map',
    28  	},
    29  	resolve: {
    30  		modules: [
    31  			'node_modules',
    32  			path.resolve(__dirname, 'components'), // import './components/Component' -> import 'Component'
    33  		],
    34  		extensions: ['.js', '.jsx'],
    35  	},
    36  	module: {
    37  		rules: [
    38  			{
    39  				test:    /\.jsx$/, // regexp for JSX files
    40  				exclude: /node_modules/,
    41  				use:     [ // order: from bottom to top
    42  					{
    43  						loader:  'babel-loader',
    44  						options: {
    45  							presets: [ // order: from bottom to top
    46  								'@babel/env',
    47  								'@babel/react',
    48  							],
    49  							plugins: [ // order: from top to bottom
    50  								'@babel/proposal-function-bind', // instead of stage 0
    51  								'@babel/proposal-class-properties', // static defaultProps
    52  								'@babel/transform-flow-strip-types',
    53  								'react-hot-loader/babel',
    54  							],
    55  						},
    56  					},
    57  					// 'eslint-loader', // show errors in the console
    58  				],
    59  			},
    60  			{
    61  				test:  /\.css$/,
    62  				oneOf: [
    63  					{
    64  						test: /font-awesome/,
    65  						use:  [
    66  							'style-loader',
    67  							'css-loader',
    68  							path.resolve(__dirname, './fa-only-woff-loader.js'),
    69  						],
    70  					},
    71  					{
    72  						use: [
    73  							'style-loader',
    74  							'css-loader',
    75  						],
    76  					},
    77  				],
    78  			},
    79  			{
    80  				test: /\.woff2?$/, // font-awesome icons
    81  				use:  'url-loader',
    82  			},
    83  		],
    84  	},
    85  };