UNPKG

brahma-trade-widget

Version:

A React component for trade automation within the Brahma ecosystem.

93 lines (91 loc) 2.44 kB
const path = require("path") const webpack = require("webpack") const TerserPlugin = require("terser-webpack-plugin") const MiniCssExtractPlugin = require("mini-css-extract-plugin") const { CleanWebpackPlugin } = require("clean-webpack-plugin") const CopyWebpackPlugin = require("copy-webpack-plugin") const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer") const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin") module.exports = { entry: "./src/index.ts", output: { filename: "index.js", path: path.resolve(__dirname, "dist"), libraryTarget: "commonjs2", }, resolve: { extensions: [".ts", ".tsx", ".js", ".jsx", ".json"], alias: { "@": path.resolve(__dirname, "src"), }, }, module: { rules: [ { test: /\.tsx?$/, use: [ { loader: "babel-loader", }, { loader: "ts-loader", options: { transpileOnly: true, // Use transpileOnly mode to speed up compilation configFile: path.resolve(__dirname, "tsconfig.json"), }, }, ], exclude: /node_modules/, }, { test: /\.css$/, use: [MiniCssExtractPlugin.loader, "css-loader"], }, { test: /\.(png|jpe?g|gif|svg|webp)$/, // Include webp use: [ { loader: "url-loader", options: { limit: 8192, // Inline files smaller than 8kb as base64 name: "images/[name].[hash].[ext]", }, }, ], }, ], }, plugins: [ new CleanWebpackPlugin(), new MiniCssExtractPlugin({ filename: "[name].css", }), new ForkTsCheckerWebpackPlugin({ async: false, typescript: { configFile: path.resolve(__dirname, "tsconfig.json"), mode: "write-references", // This will generate .d.ts files }, }), new webpack.DefinePlugin({ "process.env.NODE_ENV": JSON.stringify( process.env.NODE_ENV || "development", ), }), new CopyWebpackPlugin({ patterns: [{ from: "public", to: "public" }], }), new BundleAnalyzerPlugin({ analyzerMode: "static", openAnalyzer: false, }), ], optimization: { minimize: true, minimizer: [new TerserPlugin()], }, externals: { react: "react", "react-dom": "react-dom", }, }