text: const path = require("path");
  const webpack = require("webpack");
  const fableUtils = require("fable-utils");
  const HtmlWebpackPlugin = require('html-webpack-plugin');
  const MiniCssExtractPlugin = require("mini-css-extract-plugin");
  const CopyWebpackPlugin = require('copy-webpack-plugin');
  
  
  function resolve(filePath) {
      return path.join(__dirname, filePath)
  }
  
  var babelOptions = fableUtils.resolveBabelOptions({
      presets: [
          ["env", {
              "targets": {
                  "browsers": ["last 2 versions"]
              },
              "modules": false
          }]
      ]
  });
  
  var isProduction = process.argv.indexOf("-p") >= 0;
  console.log("Bundling for " + (isProduction ? "production" : "development") + "...");
  
  var commonPlugins = [
      new HtmlWebpackPlugin({
          filename: resolve('./output/index.html'),
          template: resolve('./src/index.html')
      })
  ];
  
  module.exports = {
      devtool: undefined,
      entry: isProduction ? // We don't use the same entry for dev and production, to make HMR over style quicker for dev env
          {
              demo: [
                  "babel-polyfill",
                  resolve('./src/Kaladin.fsproj'),
                  resolve('./src/scss/main.scss')
              ]
          } : {
              app: [
                  "babel-polyfill",
                  resolve('./src/Kaladin.fsproj')
              ],
              style: [
                  resolve('./src/scss/main.scss')
              ]
          },
      mode: isProduction ? "production" : "development",
      output: {
          path: resolve('./output'),
          filename: isProduction ? '[name].[hash].js' : '[name].js'
      },
      plugins: isProduction ?
          commonPlugins.concat([
              new MiniCssExtractPlugin({
                  filename: 'style.css'
              }),
              new CopyWebpackPlugin([
                  { from: './static' }
              ])
          ])
          : commonPlugins.concat([
              new webpack.HotModuleReplacementPlugin(),
              new webpack.NamedModulesPlugin()
          ]),
      resolve: {
          modules: [
              "node_modules/",
              resolve("./node_modules/")
          ]
      },
      devServer: {
          contentBase: resolve('./static/'),
          publicPath: "/",
          port: 8080,
          hot: true,
          inline: true
      },
      module: {
          rules: [
              {
                  test: /\.fs(x|proj)?$/,
                  use: {
                      loader: "fable-loader",
                      options: {
                          babel: babelOptions,
                          define: isProduction ? [] : ["DEBUG"],
                          extra: { optimizeWatch: true }
                      }
                  }
              },
              {
                  test: /\.js$/,
                  exclude: /node_modules/,
                  use: {
                      loader: 'babel-loader',
                      options: babelOptions
                  },
              },
              {
                  test: /\.s?[ac]ss$/,
                  use: [
                      isProduction ? MiniCssExtractPlugin.loader : 'style-loader',
                      'css-loader',
                      'sass-loader',
                  ],
              },
              {
                  test: /\.css$/,
                  use: ['style-loader', 'css-loader']
              },
              {
                  test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)(\?.*$|$)/,
                  use: ["file-loader"]
              }
          ]
      }
  };
  