liusuyi
2023-04-24 4737f1e038743ced243c9e52423404d9034d6107
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const path = require('path');
const merge = require('deepmerge');
const baseConfig = require('../base-webpack.config');
 
const babelOptions = {
  presets: ['react', 'es2015'],
  plugins: ['transform-object-rest-spread']
};
 
const config = merge(baseConfig, {
  context: __dirname,
 
  entry: './main.jsx',
 
  output: {
    path: path.resolve(__dirname, 'build')
  },
 
  module: {
    rules: [
      {
        test: /\.jsx$/,
        loader: 'babel-loader',
        options: babelOptions
      },
      {
        test: /\.svg$/,
        use: [
          {
            loader: 'babel-loader',
            options: babelOptions
          },
          {
            loader: 'svg-sprite-loader',
            options: {
              runtimeGenerator: require.resolve('./svg-to-icon-component-runtime-generator'),
              runtimeOptions: {
                iconModule: './icon.jsx' // Relative to current build context folder
              }
            }
          }
        ],
      }
    ]
  }
});
 
module.exports = config;