diff options
| author | 2020-10-12 15:04:06 +0100 | |
|---|---|---|
| committer | 2020-10-12 15:04:06 +0100 | |
| commit | 0abf07647a7f56ecd4b16c3bd0b6aef9cf8052a8 (patch) | |
| tree | 324220fcdf616152d8743e59b2ac6dcb6c6db816 /webpack.config.js | |
| parent | Merge pull request #22 from python-discord/sentry/add-sentry-prefix (diff) | |
| parent | Remove unused dependencies (diff) | |
Merge pull request #23 from python-discord/build/new-process
Introduce new build system: SWC
Diffstat (limited to 'webpack.config.js')
| -rw-r--r-- | webpack.config.js | 93 | 
1 files changed, 93 insertions, 0 deletions
| diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..49bcd76 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,93 @@ +const path = require("path") +const HtmlWebpackPlugin = require("html-webpack-plugin"); +const CopyPlugin = require('copy-webpack-plugin'); +const webpack = require("webpack") + +module.exports = (env) => { +  return { +    entry: "./src/index.tsx", +    mode: env, +    output: { +      path: path.resolve(__dirname, "build"), +      filename: "[name].[contenthash].bundle.js", +      publicPath: "/", +      devtoolModuleFilenameTemplate: "file:///" + path.resolve(__dirname, "[resource-path]?[loaders]") +    }, +    resolve: { +      extensions: ['.js', '.jsx', '.ts', '.tsx'] +    }, +    module: { +      rules: [ +        { +          test: /\.m?js$/, +          exclude: /(node_modules|bower_components)/, +          use: { +            loader: "swc-loader", +            options: { +              jsc: { +                parser: { +                  syntax: "ecmascript", +                  jsx: true, +                  dynamicImport: true +                }, +                transform: { +                  react: { +                    pragma: "React.createElement", +                    pragmaFrag: "React.Fragment", +                    throwIfNamespace: true, +                    development: false, +                    useBuiltins: false +                  } +                } +              } +            } +          } +        }, +        { +          test: /\.tsx?$/, +          exclude: /(node_modules|bower_components)/, +          use: { +            loader: "swc-loader", +            options: { +              jsc: { +                parser: { +                  syntax: "typescript", +                  tsx: true, +                  dynamicImport: true +                } +              } +            } +          } +        }, +        { +          test: /\.svg$/, +          loader: '@svgr/webpack' +        } +      ] +    }, +    devServer: { +      contentBase: path.join(__dirname, 'public'), +      compress: true, +      port: 3000, +      historyApiFallback: true, +    }, +    plugins: [ +      new CopyPlugin({ +        patterns: [ +          { from: 'public', to: '.' }, +        ], +      }), +      new webpack.EnvironmentPlugin({ +        NODE_ENV: "production", +        REACT_APP_SHA: "development", +        REACT_APP_SENTRY_DSN: "development", +        REACT_APP_BRANCH: "development", +        REACT_APP_OAUTH2_CLIENT_ID: "0" +      }), +      new HtmlWebpackPlugin({ +        inject: true, +        template: 'public/index.html' +      }) +    ] +  } +} | 
