// Template for webpack.config.js in Fable projects // Find latest version in https://github.com/fable-compiler/webpack-config-template // In most cases, you'll only need to edit the CONFIG object (after dependencies) // See below if you need better fine-tuning of Webpack options // Dependencies. Also required: core-js, fable-loader, fable-compiler, @babel/core, // @babel/preset-env, babel-loader, sass, sass-loader, css-loader, style-loader, file-loader var path = require('path'); var webpack = require('webpack'); var HtmlWebpackPlugin = require('html-webpack-plugin'); var CopyWebpackPlugin = require('copy-webpack-plugin'); var MiniCssExtractPlugin = require('mini-css-extract-plugin'); var CONFIG = { // The tags to include the generated JS and CSS will be automatically injected in the HTML template // See https://github.com/jantimon/html-webpack-plugin indexHtmlTemplate: './src/Client/index.html', fsharpEntry: './src/Client/Client.fsproj', cssEntry: './src/Client/style.scss', outputDir: './src/Client/deploy', assetsDir: './src/Client/public', devServerPort: 8080, // When using webpack-dev-server, you may need to redirect some calls // to a external API server. See https://webpack.js.org/configuration/dev-server/#devserver-proxy devServerProxy: { // redirect requests that start with /api/* to the server on port 8085 '/api/*': { target: 'http://localhost:' + (process.env.SERVER_PROXY_PORT || "8085"), changeOrigin: true }, // redirect websocket requests that start with /socket/* to the server on the port 8085 '/socket/*': { target: 'http://localhost:' + (process.env.SERVER_PROXY_PORT || "8085"), ws: true } }, // Use babel-preset-env to generate JS compatible with most-used browsers. // More info at https://babeljs.io/docs/en/next/babel-preset-env.html babel: { presets: [ ['@babel/preset-env', { modules: false, // This adds polyfills when needed. Requires core-js dependency. // See https://babeljs.io/docs/en/babel-preset-env#usebuiltins useBuiltIns: 'usage', corejs: 3 }] ], } } // If we're running the webpack-dev-server, assume we're in development mode var isProduction = !process.argv.find(v => v.indexOf('webpack-dev-server') !== -1); console.log('Bundling for ' + (isProduction ? 'production' : 'development') + '...'); // The HtmlWebpackPlugin allows us to use a template for the index.html page // and automatically injects