storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/browser/webpack.config.js (about)

     1  /*
     2   * MinIO Cloud Storage (C) 2016 MinIO, Inc.
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *     http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  
    17  var webpack = require('webpack')
    18  var path = require('path')
    19  var glob = require('glob-all')
    20  var CopyWebpackPlugin = require('copy-webpack-plugin')
    21  var PurgecssPlugin = require('purgecss-webpack-plugin')
    22  
    23  var exports = {
    24    context: __dirname,
    25    mode: 'development',
    26    entry: [
    27      path.resolve(__dirname, 'app/index.js')
    28    ],
    29    output: {
    30      path: path.resolve(__dirname, 'dev'),
    31      filename: 'index_bundle.js',
    32      publicPath: '/minio/'
    33    },
    34    module: {
    35      rules: [{
    36          test: /\.js$/,
    37          exclude: /(node_modules|bower_components)/,
    38          use: [{
    39            loader: 'babel-loader',
    40            options: {
    41              presets: ['react', 'es2015']
    42            }
    43          }]
    44        }, {
    45          test: /\.less$/,
    46          use: [{
    47            loader: 'style-loader'
    48          }, {
    49            loader: 'css-loader'
    50          }, {
    51            loader: 'less-loader'
    52          }]
    53        }, {
    54          test: /\.css$/,
    55          use: [{
    56            loader: 'style-loader'
    57          }, {
    58            loader: 'css-loader'
    59          }]
    60        }, {
    61          test: /\.(eot|woff|woff2|ttf|svg|png)/,
    62          use: [{
    63            loader: 'url-loader'
    64          }]
    65        }]
    66    },
    67    node:{
    68      fs:'empty'
    69    },
    70    devServer: {
    71      historyApiFallback: {
    72        index: '/minio/'
    73      },
    74      proxy: {
    75        '/minio/webrpc': {
    76          target: 'http://localhost:9000',
    77          secure: false,
    78          headers: {'Host': "localhost:9000"}
    79        },
    80        '/minio/upload/*': {
    81          target: 'http://localhost:9000',
    82          secure: false
    83        },
    84        '/minio/download/*': {
    85          target: 'http://localhost:9000',
    86          secure: false
    87        },
    88        '/minio/zip': {
    89          target: 'http://localhost:9000',
    90          secure: false
    91        }
    92      }
    93    },
    94    plugins: [
    95      new CopyWebpackPlugin({patterns: [
    96        {from: 'app/css/loader.css'},
    97        {from: 'app/img/browsers/chrome.png'},
    98        {from: 'app/img/browsers/firefox.png'},
    99        {from: 'app/img/browsers/safari.png'},
   100        {from: 'app/img/logo.svg'},
   101        {from: 'app/img/favicon/favicon-16x16.png'},
   102        {from: 'app/img/favicon/favicon-32x32.png'},
   103        {from: 'app/img/favicon/favicon-96x96.png'},
   104        {from: 'app/index.html'}
   105      ]}),
   106      new webpack.ContextReplacementPlugin(/moment[\\\/]locale$/, /^\.\/(en)$/),
   107      new PurgecssPlugin({
   108        paths: glob.sync([
   109          path.join(__dirname, 'app/index.html'),
   110          path.join(__dirname, 'app/js/*.js')
   111        ])
   112      })
   113    ]
   114  }
   115  
   116  if (process.env.NODE_ENV === 'dev') {
   117    exports.entry = [
   118      'webpack-dev-server/client?http://localhost:8080',
   119      path.resolve(__dirname, 'app/index.js')
   120    ]
   121  }
   122  
   123  module.exports = exports