| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- // Copyright (c) Meta Platforms, Inc. and affiliates.
- // All rights reserved.
- // This source code is licensed under the license found in the
- // LICENSE file in the root directory of this source tree.
- const { resolve } = require("path");
- const HtmlWebpackPlugin = require("html-webpack-plugin");
- const FriendlyErrorsWebpackPlugin = require("friendly-errors-webpack-plugin");
- const CopyPlugin = require("copy-webpack-plugin");
- const webpack = require("webpack");
- module.exports = {
- entry: "./src/index.tsx",
- resolve: {
- extensions: [".js", ".jsx", ".ts", ".tsx"],
- },
- output: {
- path: resolve(__dirname, "dist"),
- },
- module: {
- rules: [
- {
- test: /\.mjs$/,
- include: /node_modules/,
- type: "javascript/auto",
- resolve: {
- fullySpecified: false,
- },
- },
- {
- test: [/\.jsx?$/, /\.tsx?$/],
- use: ["ts-loader"],
- exclude: /node_modules/,
- },
- {
- test: /\.css$/,
- use: ["style-loader", "css-loader"],
- },
- {
- test: /\.(scss|sass)$/,
- use: ["style-loader", "css-loader", "postcss-loader"],
- },
- {
- test: /\.(jpe?g|png|gif|svg)$/i,
- use: [
- "file-loader?hash=sha512&digest=hex&name=img/[contenthash].[ext]",
- "image-webpack-loader?bypassOnDebug&optipng.optimizationLevel=7&gifsicle.interlaced=false",
- ],
- },
- {
- test: /\.(woff|woff2|ttf)$/,
- use: {
- loader: "url-loader",
- },
- },
- ],
- },
- plugins: [
- new CopyPlugin({
- patterns: [
- {
- from: "node_modules/onnxruntime-web/dist/*.wasm",
- to: "[name][ext]",
- },
- {
- from: "model",
- to: "model",
- },
- {
- from: "src/assets",
- to: "assets",
- },
- ],
- }),
- new HtmlWebpackPlugin({
- template: "./src/assets/index.html",
- }),
- new FriendlyErrorsWebpackPlugin(),
- new webpack.ProvidePlugin({
- process: "process/browser",
- }),
- ],
- };
|