Skip to content
Snippets Groups Projects
Select Git revision
  • 9f004860c9697728b3f4616b43682eeadf63662e
  • develop default
  • master protected
  • feature/frontend-tests
  • 0.110
  • 0.109
  • 0.108
  • 0.107
  • 0.106
  • 0.105
  • 0.104
  • 0.103
  • 0.102
  • 0.101
  • 0.100
  • 0.99
  • 0.98
  • 0.97
  • 0.96
  • 0.95
  • 0.94
  • 0.93
  • 0.92
  • 0.91
24 results

webpack.config.ts

Blame
  • webpack.config.ts 1.94 KiB
    import path from "path";
    import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin";
    
    import { Configuration as WebpackConfiguration } from "webpack";
    import { Configuration as WebpackDevServerConfiguration } from "webpack-dev-server";
    
    interface Configuration extends WebpackConfiguration {
      devServer?: WebpackDevServerConfiguration;
    }
    
    const config: Configuration = {
      entry: "./src/index.tsx",
      module: {
        rules: [
          {
            test: /\.(ts|js)x?$/,
            exclude: /node_modules/,
            use: {
              loader: "babel-loader",
              options: {
                presets: [
                  "@babel/preset-env",
                  "@babel/preset-react",
                  "@babel/preset-typescript",
                ],
              },
            },
          },
          {
            test: /\.scss$/,
            exclude: /node_modules/,
            use: [
              { loader: "style-loader" },
              { loader: "css-loader" },
              { loader: "sass-loader" },
            ],
          },
          {
            test: /\.css$/,
            use: [{ loader: "style-loader" }, { loader: "css-loader" }],
          },
          {
            test: /\.(png|svg|jpe?g|gif)$/,
            type: "asset/resource"
          },
        ],
      },
      resolve: {
        extensions: [".tsx", ".ts", ".js", ".html"],
      },
      output: {
        path: path.resolve(__dirname, "..", "compendium_v2", "static"),
        filename: "bundle.js",
      },
      devServer: {
        static: path.join(__dirname, "..", "compendium_v2", "static"),
        compress: true,
        port: 4000,
        // Allow SPA urls to work with dev-server
        historyApiFallback: true,
        proxy: {
          "/api": "http://127.0.0.1:5000",
          "/login": "http://127.0.0.1:5000",
          "/logout": "http://127.0.0.1:5000",
          "/authorize": "http://127.0.0.1:5000",
          "/survey/*": "http://127.0.0.1:4001"
        },
      },
      devtool: process.env.NODE_ENV === "production" ? undefined : "inline-source-map",
      plugins: [
        new ForkTsCheckerWebpackPlugin({
          async: false,
        }),
      ],
    };
    
    export default config;